diff --git a/x/config/config.go b/x/config/config.go index a93b8517..0dfe0a44 100644 --- a/x/config/config.go +++ b/x/config/config.go @@ -120,21 +120,23 @@ func newPacketDialerFromPart(innerDialer transport.PacketDialer, oneDialerConfig } } -// NewShadowsocksPacketListenerFromPart creates a new [transport.PacketListener] according to the given config, +// NewpacketListener creates a new [transport.PacketListener] according to the given config, // the config must contain only one "ss://" segment. -func NewShadowsocksPacketListenerFromPart(ssConfig string) (transport.PacketListener, error) { - ssConfig = strings.TrimSpace(ssConfig) - if ssConfig == "" { - return nil, errors.New("empty config part") +func NewpacketListener(transportConfig string) (transport.PacketListener, error) { + if transportConfig = strings.TrimSpace(transportConfig); transportConfig == "" { + return nil, errors.New("config is required") + } + if strings.Contains(transportConfig, "|") { + return nil, errors.New("multi-part config is not supported") } - url, err := url.Parse(ssConfig) + url, err := url.Parse(transportConfig) if err != nil { - return nil, fmt.Errorf("failed to parse config part: %w", err) + return nil, fmt.Errorf("failed to parse config: %w", err) } - if url.Scheme != "ss" { return nil, errors.New("config scheme must be 'ss' for a PacketListener") } + return newShadowsocksPacketListenerFromURL(url) } diff --git a/x/examples/outline-cli/README.md b/x/examples/outline-cli/README.md index 80707150..e0dfb8a1 100644 --- a/x/examples/outline-cli/README.md +++ b/x/examples/outline-cli/README.md @@ -2,29 +2,22 @@ The CLI interface of OutlineVPN client for Linux. -## Usage - -#### Standard - -``` -./outline-cli -transport "ss://" -``` - -#### Advanced (with Golang) +### Usage ``` go run github.com/Jigsaw-Code/outline-sdk/x/examples/outline-cli@latest -transport "ss://" ``` -### Arguments - - `-transport` : the Outline server access key from the service provider, it should start with "ss://" -## Build (for Developers) +### Build + +You can use the following command to build the CLI. -We recommend to setup a [go workspace](https://go.dev/blog/get-familiar-with-workspaces) to build the code. Then use the following command to build the CLI (only support Linux): ``` cd outline-sdk/x/examples/ go build -o outline-cli -ldflags="-extldflags=-static" ./outline-cli ``` + +> 💡 `cgo` will pull in the C runtime. By default, the C runtime is linked as a dynamic library. Sometimes this can cause problems when running the binary on different versions or distributions of Linux. To avoid this, we have added the `-ldflags="-extldflags=-static"` option. But if you only need to run the binary on the same machine, you can omit this option. diff --git a/x/examples/outline-cli/outline_packet_proxy.go b/x/examples/outline-cli/outline_packet_proxy.go index 386ef627..d9b24a9a 100644 --- a/x/examples/outline-cli/outline_packet_proxy.go +++ b/x/examples/outline-cli/outline_packet_proxy.go @@ -36,7 +36,7 @@ type outlinePacketProxy struct { func newOutlinePacketProxy(transportConfig string) (opp *outlinePacketProxy, err error) { opp = &outlinePacketProxy{} - if opp.remotePl, err = config.NewShadowsocksPacketListenerFromPart(transportConfig); err != nil { + if opp.remotePl, err = config.NewpacketListener(transportConfig); err != nil { return nil, fmt.Errorf("failed to create UDP packet listener: %w", err) } if opp.remote, err = network.NewPacketProxyFromPacketListener(opp.remotePl); err != nil {