Jigsaw-Code / outline-sdk

SDK to build network tools based on Outline components.
https://getoutline.org/for-developers/
Apache License 2.0
232 stars 27 forks source link

Any way to run Outline client on linux server terminal by command line? #194

Open alexlii1971 opened 4 months ago

alexlii1971 commented 4 months ago

Hello,

We have a server in China, and the server with Ubuntu is limited to access any global resource.

So, is there any way to run outline client on Linux terminal by command line?

Thanks

alexlii1971 commented 4 months ago

Hello,

I got the post at https://github.com/Jigsaw-Code/outline-sdk/blob/main/x/examples/outline-cli/README.md

Outline VPN Command-Line Client

A CLI interface of Outline VPN client for Linux.

Usage

go run github.com/Jigsaw-Code/outline-sdk/x/examples/outline-cli@latest -transport "ss://<outline-server-access-key>"

Build

You can use the following command to build the CLI.

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.

You know, we would run it on server temporally, and we need stop outline service running on server after deploy the project.

so, any way to get VPN client outline and down, and stop running?

alexlii1971 commented 4 months ago

Hello,

Here is the error on Ubuntu, anyway to fix?

go run github.com/Jigsaw-Code/outline-sdk/x/examples/outline-cli@latest -transport "ss://Y2hhY2hhMjAtaWV0Zi1wb2x5MTMwNTpzJRYXgwdGdqeXZQ@24.199.120.10:44194/?outline=1>"

github.com/Jigsaw-Code/outline-sdk/transport

go/pkg/mod/github.com/!jigsaw-!code/outline-sdk@v0.0.14-0.20240216220040-f741c57bf854/transport/happyeyeballs.go:90:22: undefined: atomic.Int32 go/pkg/mod/github.com/!jigsaw-!code/outline-sdk@v0.0.14-0.20240216220040-f741c57bf854/transport/happyeyeballs.go:194:24: undefined: errors.Join go/pkg/mod/github.com/!jigsaw-!code/outline-sdk@v0.0.14-0.20240216220040-f741c57bf854/transport/happyeyeballs.go:242:22: undefined: errors.Join

jyyi1 commented 3 months ago

Hi @alexlii1971 , sorry about the inconvenience, if @latest does not work for you, you can always use the commit ID tag instead, for example:

go run github.com/Jigsaw-Code/outline-sdk/x/examples/outline-cli@7294484
cinsort commented 2 months ago

Hi @jyyi1, having troubles running previous command on Ubuntu 22.04:

# github.com/Jigsaw-Code/outline-sdk/network/lwip2transport
go/pkg/mod/github.com/!jigsaw-!code/outline-sdk@v0.0.11/network/lwip2transport/device.go:35:13: undefined: lwip.LWIPStack
go/pkg/mod/github.com/!jigsaw-!code/outline-sdk@v0.0.11/network/lwip2transport/device.go:83:15: undefined: lwip.NewLWIPStack
go/pkg/mod/github.com/!jigsaw-!code/outline-sdk@v0.0.11/network/lwip2transport/device.go:90:7: undefined: lwip.RegisterOutputFn
jyyi1 commented 2 months ago

Hi @cinsort , this seems to be a Go or C/C++ compiler issue. We are using a native LwIP network stack defined here: https://github.com/eycorsican/go-tun2socks/blob/master/core/lwip.go#L21-L25 . That requires CGO_ENABLED=1 and a native C/C++ compiler installed in the system. And also GOOS needs to be linux as well.

You may confirm these setting by running go env. Also, please use go version 1.21+ to run the command.

ElGrats commented 1 month ago

Hi @cinsort , this seems to be a Go or C/C++ compiler issue. We are using a native LwIP network stack defined here: https://github.com/eycorsican/go-tun2socks/blob/master/core/lwip.go#L21-L25 . That requires CGO_ENABLED=1 and a native C/C++ compiler installed in the system. And also GOOS needs to be linux as well.

You may confirm these setting by running go env. Also, please use go version 1.21+ to run the command.

and what to do?

ElGrats commented 1 month ago

[ERROR] 2024/05/28 05:30:05 failed to configure system DNS: failed to backup DNS config file '/etc/resolv.conf.head' to '/etc/resolv.head.outlinecli.backup': rename /etc/resolv.conf.head /etc/resolv.head.outlinecli.backup: no such file or directory

jyyi1 commented 1 month ago

[ERROR] 2024/05/28 05:30:05 failed to configure system DNS: failed to backup DNS config file '/etc/resolv.conf.head' to '/etc/resolv.head.outlinecli.backup': rename /etc/resolv.conf.head /etc/resolv.head.outlinecli.backup: no such file or directory

Hi @ElGrats , this is a known issue and there is a PR to fix it: https://github.com/Jigsaw-Code/outline-sdk/pull/203. It's not quite ready yet, but feel free to contribute to it!

In the meantime, you can work-around the problem by creating an empty file named /etc/resolv.conf.head.