| 1 | /* |
| 2 | * Copyright (c) 2014, Yawning Angel <yawning at schwanenlied dot me> |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * * Redistributions of source code must retain the above copyright notice, |
| 9 | * this list of conditions and the following disclaimer. |
| 10 | * |
| 11 | * * Redistributions in binary form must reproduce the above copyright notice, |
| 12 | * this list of conditions and the following disclaimer in the documentation |
| 13 | * and/or other materials provided with the distribution. |
| 14 | * |
| 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 25 | * POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | // Package transports provides a interface to query supported pluggable |
| 29 | // transports. |
| 30 | package transportsscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports`/ // import "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports" |
| 31 | |
| 32 | import ( |
| 33 | "fmtscip-go gomod github.com/golang/go/src go1.22.0 fmt/" |
| 34 | "syncscip-go gomod github.com/golang/go/src go1.22.0 sync/" |
| 35 | |
| 36 | "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/snowflakescip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/snowflake`/" |
| 37 | "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnelscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/" |
| 38 | |
| 39 | "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/basescip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/base`/" |
| 40 | "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/meeklitescip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/meeklite`/" |
| 41 | "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/obfs2scip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/obfs2`/" |
| 42 | "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/obfs3scip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/obfs3`/" |
| 43 | "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/obfs4scip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/obfs4`/" |
| 44 | "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/scramblesuitscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/scramblesuit`/" |
| 45 | ) |
| 46 | |
| 47 | var transportMapLockscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports`/transportMapLock. syncscip-go gomod github.com/golang/go/src go1.22.0 sync/.Mutexscip-go gomod github.com/golang/go/src go1.22.0 sync/Mutex# |
| 48 | var transportMapscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports`/transportMap. map[string]basescip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/base`/.Transportscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/base`/Transport# = make(map[string]basescip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/base`/.Transportscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/base`/Transport#) |
| 49 | |
| 50 | // Register registers a transport protocol. |
| 51 | func Registerscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports`/Register().(transport basescip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/base`/.Transportscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/base`/Transport#) error { |
| 52 | transportMapLockscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports`/transportMapLock..Lockscip-go gomod github.com/golang/go/src go1.22.0 sync/Mutex#Lock().() |
| 53 | defer transportMapLockscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports`/transportMapLock..Unlockscip-go gomod github.com/golang/go/src go1.22.0 sync/Mutex#Unlock().() |
| 54 | |
| 55 | name := transport.Namescip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/base`/Transport#Name.() |
| 56 | _, registered := transportMapscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports`/transportMap.[name] |
| 57 | if registered { |
| 58 | return fmtscip-go gomod github.com/golang/go/src go1.22.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.22.0 fmt/Errorf().("transport '%s' already registered", name) |
| 59 | } |
| 60 | transportMapscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports`/transportMap.[name] = transport |
| 61 | |
| 62 | return nil |
| 63 | } |
| 64 | |
| 65 | // Transports returns the list of registered transport protocols. |
| 66 | func Transportsscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports`/Transports().() []string { |
| 67 | transportMapLockscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports`/transportMapLock..Lockscip-go gomod github.com/golang/go/src go1.22.0 sync/Mutex#Lock().() |
| 68 | defer transportMapLockscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports`/transportMapLock..Unlockscip-go gomod github.com/golang/go/src go1.22.0 sync/Mutex#Unlock().() |
| 69 | |
| 70 | var ret []string |
| 71 | for name := range transportMapscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports`/transportMap. { |
| 72 | ret = append(ret, name) |
| 73 | } |
| 74 | |
| 75 | return ret |
| 76 | } |
| 77 | |
| 78 | // Get returns a transport protocol implementation by name. |
| 79 | func Getscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports`/Get().(name string) basescip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/base`/.Transportscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/base`/Transport# { |
| 80 | transportMapLockscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports`/transportMapLock..Lockscip-go gomod github.com/golang/go/src go1.22.0 sync/Mutex#Lock().() |
| 81 | defer transportMapLockscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports`/transportMapLock..Unlockscip-go gomod github.com/golang/go/src go1.22.0 sync/Mutex#Unlock().() |
| 82 | |
| 83 | t := transportMapscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports`/transportMap.[name] |
| 84 | |
| 85 | return t |
| 86 | } |
| 87 | |
| 88 | // Init initializes all of the integrated transports. |
| 89 | func Initscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports`/Init().() error { |
| 90 | for _, v := range []basescip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/base`/.Transportscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/base`/Transport#{ |
| 91 | new(meeklitescip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/meeklite`/.Transportscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/meeklite`/Transport#), |
| 92 | new(obfs2scip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/obfs2`/.Transportscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/obfs2`/Transport#), |
| 93 | new(obfs3scip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/obfs3`/.Transportscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/obfs3`/Transport#), |
| 94 | new(obfs4scip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/obfs4`/.Transportscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/obfs4`/Transport#), |
| 95 | new(scramblesuitscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/scramblesuit`/.Transportscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/scramblesuit`/Transport#), |
| 96 | new(snowflakescip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/snowflake`/.Transportscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/snowflake`/Transport#), |
| 97 | webtunnelscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/.Transportscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/Transport., |
| 98 | } { |
| 99 | if err := Registerscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports`/Register().(v); err != nil { |
| 100 | return err |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | return nil |
| 105 | } |