Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin service exit unexpectedly #30

Open
x0r2d2 opened this issue Apr 4, 2018 · 16 comments
Open

plugin service exit unexpectedly #30

x0r2d2 opened this issue Apr 4, 2018 · 16 comments

Comments

@x0r2d2
Copy link
Contributor

x0r2d2 commented Apr 4, 2018

SS-libev version: 3.1.3
GQ server version: 1.1.2
TFO: false

I have added some additional commands to install GoQuiet with teddysun's autoinstall script but finally I don't understand why the GQ plugin is not working. Maybe I am doing something wrong.
Can somebody help on this matter, please?
Script: https://github.com/hybtoy/shadowsocks_install/blob/master/shadowsocks-libev-debian.sh

SSL config:
{
"server":${server_value},
"server_port":${shadowsocksport},
"local_address":"127.0.0.1",
"local_port":1080,
"method":"${shadowsockscipher}",
"password":"${password}",
"timeout":600,
"udp_timeout":600,
"mode":"tcp_and_udp",
"fast_open":false,
"no_delay":true,
"reuse_port":true,
"verbose":true,
"plugin":"/etc/shadowsocks-libev/gqserver",
"plugin_opts":"/etc/shadowsocks-libev/gqserver.json"
}

GQ server config:

{
"WebServerAddr":"${obfshost}:443",
"Key":"${password}",
"FastOpen":false,
}

Log:
`shadowsocks.service - LSB: Fast tunnel proxy that helps you bypass firewalls
Loaded: loaded (/etc/init.d/shadowsocks; bad; vendor preset: enabled)
Active: active (running) since Wed 2018-04-04 07:20:35 CEST; 2s ago
Docs: man:systemd-sysv-generator(8)
Process: 849 ExecStop=/etc/init.d/shadowsocks stop (code=exited, status=0/SUCCESS)
Process: 853 ExecStart=/etc/init.d/shadowsocks start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/shadowsocks.service
-699 /etc/shadowsocks-libev/gqserver

Apr 04 07:20:35 mail2you /usr/local/bin/ss-server[855]: plugin "/etc/shadowsocks-libev/gqserver" enabled
Apr 04 07:20:35 mail2you /usr/local/bin/ss-server[855]: UDP relay enabled
Apr 04 07:20:35 mail2you /usr/local/bin/ss-server[855]: enable TCP no-delay
Apr 04 07:20:35 mail2you /usr/local/bin/ss-server[855]: initializing ciphers... aes-128-gcm
Apr 04 07:20:35 mail2you /usr/local/bin/ss-server[855]: tcp server listening at 127.0.0.1:57593
Apr 04 07:20:35 mail2you /usr/local/bin/ss-server[855]: tcp port reuse enabled
Apr 04 07:20:35 mail2you /usr/local/bin/ss-server[855]: udp server listening at 0.0.0.0:443
Apr 04 07:20:35 mail2you /usr/local/bin/ss-server[855]: udp port reuse enabled
Apr 04 07:20:35 mail2you /usr/local/bin/ss-server[855]: running from root user
Apr 04 07:20:35 mail2you /usr/local/bin/ss-server[855]: plugin service exit unexpectedly
`

@x0r2d2 x0r2d2 changed the title Plugin service exit unexpectadly plugin service exit unexpectedly Apr 4, 2018
@x0r2d2
Copy link
Contributor Author

x0r2d2 commented Apr 4, 2018

On another test server plugin working as expected but SSL has been installed from max-c-lv repository.
https://github.com/shadowsocks/shadowsocks-libev#debian--ubuntu

@x0r2d2
Copy link
Contributor Author

x0r2d2 commented Apr 4, 2018

root@mail2you:~# netstat -tulpn | grep 443
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      594/gqserver
root@mail2you:~# ^C
root@mail2you:~# service shadowsocks start
root@mail2you:~# service shadowsocks status
* shadowsocks.service - LSB: Fast tunnel proxy that helps you bypass firewalls
   Loaded: loaded (/etc/init.d/shadowsocks; bad; vendor preset: enabled)
   Active: active (running) since Wed 2018-04-04 08:05:44 CEST; 1s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 665 ExecStop=/etc/init.d/shadowsocks stop (code=exited, status=1/FAILURE)
  Process: 712 ExecStart=/etc/init.d/shadowsocks start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/shadowsocks.service
           `-594 /etc/shadowsocks-libev/gqserver

Apr 04 08:05:44 mail2you /usr/local/bin/ss-server[714]: plugin "/etc/shadowsocks-libev/gqserver" enabled
Apr 04 08:05:44 mail2you /usr/local/bin/ss-server[714]: UDP relay enabled
Apr 04 08:05:44 mail2you /usr/local/bin/ss-server[714]: enable TCP no-delay
Apr 04 08:05:44 mail2you /usr/local/bin/ss-server[714]: initializing ciphers... aes-128-gcm
Apr 04 08:05:44 mail2you /usr/local/bin/ss-server[714]: tcp server listening at 127.0.0.1:46503
Apr 04 08:05:44 mail2you /usr/local/bin/ss-server[714]: tcp port reuse enabled
Apr 04 08:05:44 mail2you /usr/local/bin/ss-server[714]: udp server listening at 0.0.0.0:443
Apr 04 08:05:44 mail2you /usr/local/bin/ss-server[714]: udp port reuse enabled
Apr 04 08:05:44 mail2you /usr/local/bin/ss-server[714]: running from root user
Apr 04 08:05:44 mail2you /usr/local/bin/ss-server[714]: plugin service exit unexpectedly
root@mail2you:~# netstat -tulpn | grep 443
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      594/gqserver
root@mail2you:~#

@kimw
Copy link
Contributor

kimw commented Apr 4, 2018

Did you try to build GQ from source? There's some new patch since the last release out.

@x0r2d2
Copy link
Contributor Author

x0r2d2 commented Apr 4, 2018

@kimw I use binaries. Do I need to build it anyway?

@kimw
Copy link
Contributor

kimw commented Apr 4, 2018

@hybtoy It's just a suggestion. Maybe it works, maybe not. Let's see it.


BTW, build GQ from source code is easy to practice.

  1. Download the binary package from https://dl.google.com/go/go1.9.5.linux-amd64.tar.gz
  2. Unpack it by,
    sudo tar -zxf go1.9.5.linux-amd64.tar.gz -C /usr/local
  3. Set up GO environment by,
    cat >> ~/.bashrc <<EOF
    export PATH=/usr/local/go/bin:$PATH
    export GOROOT=$(go env GOROOT)
    export GOPATH=$(go env GOPATH)
    export GOBIN=$GOPATH/bin
    export PATH=$GOBIN:$PATH
    EOF
  4. Renew your terminal envs by source ~/.bashrc
  5. Clone GQ by go get github.com/cbeuw/GoQuiet
  6. Build it by (cd ~/go/src/github.com/cbeuw/GoQuiet; make)

Now the GQ is built and stored in ~/go/bin/src/github.com/cbeuw/GoQuiet/build.

@kimw
Copy link
Contributor

kimw commented Apr 4, 2018

Here's the remove steps maybe is useful for you,

  1. Remove user's workspace, rm -rf ~/go
  2. Remove user's bash envs
    sed -i -e '/^export PATH=\/usr\/local\/go\/bin:$PATH$/d;' ~/.bashrc
    sed -i -e '/^export GOROOT=\$\(go env GOROOT\)$/d;' ~/.bashrc
    sed -i -e '/^export GOPATH=\$\(go env GOPATH\)$/d;' ~/.bashrc
    sed -i -e '/^export GOBIN=\$GOPATH\/bin$/d;' ~/.bashrc
    sed -i -e '/^export PATH=\$GOBIN:\$PATH$/d;' ~/.bashrc
  3. Remove system wide GO binaries, sudo rm -rf /usr/local/go

See it! It's easy.

@cbeuw
Copy link
Owner

cbeuw commented Apr 4, 2018

@kimw
I don't think the last few commits affect anything that can cause the program to crash
@hybtoy
Shadowsocks' plugin mode does not output STDERR from the plugin so I can't see the log. Can you use Standalone mode+nohup to save the log file?

@x0r2d2
Copy link
Contributor Author

x0r2d2 commented Apr 4, 2018

@cbeuw
I am starting gqserver on separate screen session like this:
gq-server -c /etc/shadowsocks-libev/gqserver.json -r 127.0.0.1:8443 -p 443
2018/04/04 15:12:46 Starting standalone mode, listening on 0.0.0.0:443 to ss at 127.0.0.1:8443
2018/04/04 15:12:46 Listening on 0.0.0.0:443

On another screen session I am starting ss with this config:
root@mail2you:~/gowork/src/github.com/cbeuw/GoQuiet/build#
ss-server -c /etc/shadowsocks-libev/config.json -s 127.0.0.1 -p 8443
2018-04-04 15:13:54 INFO: using tcp fast open
2018-04-04 15:13:54 INFO: UDP relay enabled
2018-04-04 15:13:54 INFO: enable TCP no-delay
2018-04-04 15:13:54 INFO: initializing ciphers... aes-128-gcm
2018-04-04 15:13:54 INFO: tcp server listening at 127.0.0.1:8443
2018-04-04 15:13:54 INFO: tcp port reuse enabled
2018-04-04 15:13:54 INFO: udp server listening at 127.0.0.1:8443
2018-04-04 15:13:54 INFO: udp port reuse enabled
2018-04-04 15:13:54 INFO: running from root user

And it is working

@x0r2d2
Copy link
Contributor Author

x0r2d2 commented Apr 4, 2018

After restart it began to work

root@mail2you:/etc/shadowsocks-libev# service shadowsocks restart
root@mail2you:/etc/shadowsocks-libev# service shadowsocks status

  • shadowsocks.service - LSB: Fast tunnel proxy that helps you bypass firewalls
    Loaded: loaded (/etc/init.d/shadowsocks; bad; vendor preset: enabled)
    Active: active (running) since Wed 2018-04-04 15:56:14 CEST; 1s ago
    Docs: man:systemd-sysv-generator(8)
    Process: 1018 ExecStop=/etc/init.d/shadowsocks stop (code=exited, status=1/FAILURE)
    Process: 1023 ExecStart=/etc/init.d/shadowsocks start (code=exited, status=0/SUCCESS)
    CGroup: /system.slice/shadowsocks.service
    |-1026 /usr/local/bin/ss-server -c /etc/shadowsocks-libev/config.json -f /var/run/shadowsocks-libev.pid
    `-1027 /etc/shadowsocks-libev/gqserver

Apr 04 15:56:14 mail2you /usr/local/bin/ss-server[1026]: plugin "/etc/shadowsocks-libev/gqserver" enabled
Apr 04 15:56:14 mail2you /usr/local/bin/ss-server[1026]: UDP relay enabled
Apr 04 15:56:14 mail2you /usr/local/bin/ss-server[1026]: enable TCP no-delay
Apr 04 15:56:14 mail2you /usr/local/bin/ss-server[1026]: initializing ciphers... aes-128-gcm
Apr 04 15:56:14 mail2you /usr/local/bin/ss-server[1026]: tcp server listening at 127.0.0.1:48141
Apr 04 15:56:14 mail2you /usr/local/bin/ss-server[1026]: tcp port reuse enabled
Apr 04 15:56:14 mail2you /usr/local/bin/ss-server[1026]: udp server listening at 0.0.0.0:443
Apr 04 15:56:14 mail2you /usr/local/bin/ss-server[1026]: udp port reuse enabled
Apr 04 15:56:14 mail2you /usr/local/bin/ss-server[1026]: running from root user
Apr 04 15:56:14 mail2you systemd[1]: Started LSB: Fast tunnel proxy that helps you bypass firewalls.
root@mail2you:/etc/shadowsocks-libev#

If I will restart the service, plugin will not work.

@x0r2d2
Copy link
Contributor Author

x0r2d2 commented Apr 4, 2018

And as I noticed above:

root@mail2you:/etc/shadowsocks-libev# service shadowsocks restart
root@mail2you:/etc/shadowsocks-libev# service shadowsocks status

  • shadowsocks.service - LSB: Fast tunnel proxy that helps you bypass firewalls
    Loaded: loaded (/etc/init.d/shadowsocks; bad; vendor preset: enabled)
    Active: active (running) since Wed 2018-04-04 15:56:14 CEST; 1s ago
    Docs: man:systemd-sysv-generator(8)
    Process: 1018 ExecStop=/etc/init.d/shadowsocks stop (code=exited, status=1/FAILURE)
    Process: 1023 ExecStart=/etc/init.d/shadowsocks start (code=exited, status=0/SUCCESS)
    CGroup: /system.slice/shadowsocks.service
    |-1026 /usr/local/bin/ss-server -c /etc/shadowsocks-libev/config.json -f /var/run/shadowsocks-libev.pid
    `-1027 /etc/shadowsocks-libev/gqserver

Apr 04 15:56:14 mail2you /usr/local/bin/ss-server[1026]: plugin "/etc/shadowsocks-libev/gqserver" enabled
Apr 04 15:56:14 mail2you /usr/local/bin/ss-server[1026]: UDP relay enabled
Apr 04 15:56:14 mail2you /usr/local/bin/ss-server[1026]: enable TCP no-delay
Apr 04 15:56:14 mail2you /usr/local/bin/ss-server[1026]: initializing ciphers... aes-128-gcm
Apr 04 15:56:14 mail2you /usr/local/bin/ss-server[1026]: tcp server listening at 127.0.0.1:48141
Apr 04 15:56:14 mail2you /usr/local/bin/ss-server[1026]: tcp port reuse enabled
Apr 04 15:56:14 mail2you /usr/local/bin/ss-server[1026]: udp server listening at 0.0.0.0:443
Apr 04 15:56:14 mail2you /usr/local/bin/ss-server[1026]: udp port reuse enabled
Apr 04 15:56:14 mail2you /usr/local/bin/ss-server[1026]: running from root user
Apr 04 15:56:14 mail2you systemd[1]: Started LSB: Fast tunnel proxy that helps you bypass firewalls.
root@mail2you:/etc/shadowsocks-libev# service shadowsocks restart
root@mail2you:/etc/shadowsocks-libev# service shadowsocks status

  • shadowsocks.service - LSB: Fast tunnel proxy that helps you bypass firewalls
    Loaded: loaded (/etc/init.d/shadowsocks; bad; vendor preset: enabled)
    Active: active (exited) since Wed 2018-04-04 15:57:47 CEST; 1s ago
    Docs: man:systemd-sysv-generator(8)
    Process: 1061 ExecStop=/etc/init.d/shadowsocks stop (code=exited, status=0/SUCCESS)
    Process: 1065 ExecStart=/etc/init.d/shadowsocks start (code=exited, status=0/SUCCESS)

Apr 04 15:57:47 mail2you /usr/local/bin/ss-server[1067]: plugin "/etc/shadowsocks-libev/gqserver" enabled
Apr 04 15:57:47 mail2you /usr/local/bin/ss-server[1067]: UDP relay enabled
Apr 04 15:57:47 mail2you /usr/local/bin/ss-server[1067]: enable TCP no-delay
Apr 04 15:57:47 mail2you /usr/local/bin/ss-server[1067]: initializing ciphers... aes-128-gcm
Apr 04 15:57:47 mail2you /usr/local/bin/ss-server[1067]: tcp server listening at 127.0.0.1:36503
Apr 04 15:57:47 mail2you /usr/local/bin/ss-server[1067]: tcp port reuse enabled
Apr 04 15:57:47 mail2you /usr/local/bin/ss-server[1067]: udp server listening at 0.0.0.0:443
Apr 04 15:57:47 mail2you /usr/local/bin/ss-server[1067]: udp port reuse enabled
Apr 04 15:57:47 mail2you /usr/local/bin/ss-server[1067]: running from root user
Apr 04 15:57:47 mail2you /usr/local/bin/ss-server[1067]: plugin service exit unexpectedly

@cbeuw
Copy link
Owner

cbeuw commented Apr 5, 2018

@hybtoy
It seems like the issue is with how your version of Shadowsocks passes environment variables to GQ.
Can you compile this and put the binary as --plugin and paste the output here?

#include <stdio.h>
#include <stdlib.h>
int main(){
        printf("SS_REMOTE_HOST %s\n", getenv("SS_REMOTE_HOST"));
        printf("SS_REMOTE_PORT %s\n", getenv("SS_REMOTE_PORT"));
        printf("SS_LOCAL_HOST %s\n", getenv("SS_LOCAL_HOST"));
        printf("SS_LOCAL_PORT %s\n", getenv("SS_LOCAL_PORT"));
        return 0;
}

@x0r2d2
Copy link
Contributor Author

x0r2d2 commented Apr 6, 2018

@cbeuw
I am not a professional in this kind of things :)
Could you please tell me what you need from my side step by step or I can provide you with server credentials.
Thanks.

@cbeuw
Copy link
Owner

cbeuw commented Apr 6, 2018

@hybtoy
It's not too complicated.

  1. Paste the code into a text file using a text editor and save it as env.c
  2. Run gcc env.c -o env.o. If it says gcc is not found, do sudo apt install gcc and then run the command.
  3. Edit your shadowsocks-libev configuration, change "plugin":"/etc/shadowsocks-libev/gqserver", to "plugin":"[path to env.o]",
  4. Start Shadowsocks as normal and paste the output here.
    Thanks!

@x0r2d2
Copy link
Contributor Author

x0r2d2 commented Apr 7, 2018

@cbeuw
Done.

root@mail2you:~# service shadowsocks status
* shadowsocks.service - LSB: Fast tunnel proxy that helps you bypass firewalls
   Loaded: loaded (/etc/init.d/shadowsocks; bad; vendor preset: enabled)
   Active: active (running) since Sat 2018-04-07 13:11:00 CEST; 3s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 905 ExecStop=/etc/init.d/shadowsocks stop (code=exited, status=0/SUCCESS)
  Process: 909 ExecStart=/etc/init.d/shadowsocks start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/shadowsocks.service
           `-609 /etc/shadowsocks-libev/gqserver

Apr 07 13:11:00 mail2you /usr/local/bin/ss-server[911]: plugin "/etc/shadowsocks-libev/gqserver" enabled
Apr 07 13:11:00 mail2you /usr/local/bin/ss-server[911]: UDP relay enabled
Apr 07 13:11:00 mail2you /usr/local/bin/ss-server[911]: enable TCP no-delay
Apr 07 13:11:00 mail2you /usr/local/bin/ss-server[911]: initializing ciphers... aes-256-gcm
Apr 07 13:11:00 mail2you /usr/local/bin/ss-server[911]: tcp server listening at 127.0.0.1:48133
Apr 07 13:11:00 mail2you /usr/local/bin/ss-server[911]: tcp port reuse enabled
Apr 07 13:11:00 mail2you /usr/local/bin/ss-server[911]: udp server listening at 0.0.0.0:443
Apr 07 13:11:00 mail2you /usr/local/bin/ss-server[911]: udp port reuse enabled
Apr 07 13:11:00 mail2you /usr/local/bin/ss-server[911]: running from root user
Apr 07 13:11:00 mail2you /usr/local/bin/ss-server[911]: plugin service exit unexpectedly

root@mail2you:/etc/shadowsocks-libev# service shadowsocks restart
root@mail2you:/etc/shadowsocks-libev# service shadowsocks status
* shadowsocks.service - LSB: Fast tunnel proxy that helps you bypass firewalls
   Loaded: loaded (/etc/init.d/shadowsocks; bad; vendor preset: enabled)
   Active: active (running) since Sat 2018-04-07 13:13:10 CEST; 4s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 997 ExecStop=/etc/init.d/shadowsocks stop (code=exited, status=1/FAILURE)
  Process: 1001 ExecStart=/etc/init.d/shadowsocks start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/shadowsocks.service
           `-609 /etc/shadowsocks-libev/gqserver

Apr 07 13:13:10 mail2you /usr/local/bin/ss-server[1003]: plugin "/etc/shadowsocks-libev/env.o" enabled
Apr 07 13:13:10 mail2you /usr/local/bin/ss-server[1003]: UDP relay enabled
Apr 07 13:13:10 mail2you /usr/local/bin/ss-server[1003]: enable TCP no-delay
Apr 07 13:13:10 mail2you /usr/local/bin/ss-server[1003]: initializing ciphers... aes-256-gcm
Apr 07 13:13:10 mail2you /usr/local/bin/ss-server[1003]: tcp server listening at 127.0.0.1:34306
Apr 07 13:13:10 mail2you /usr/local/bin/ss-server[1003]: tcp port reuse enabled
Apr 07 13:13:10 mail2you /usr/local/bin/ss-server[1003]: udp server listening at 0.0.0.0:443
Apr 07 13:13:10 mail2you /usr/local/bin/ss-server[1003]: udp port reuse enabled
Apr 07 13:13:10 mail2you /usr/local/bin/ss-server[1003]: running from root user
Apr 07 13:13:10 mail2you systemd[1]: Started LSB: Fast tunnel proxy that helps you bypass firewalls.

@kimw
Copy link
Contributor

kimw commented Apr 10, 2018

@hybtoy Please try the attached one, which should output like,

 2018-04-09 19:49:23 INFO: initializing acl...
 2018-04-09 19:49:23 INFO: plugin "/usr/local/bin/gq-server" enabled
 2018-04-09 19:49:23 INFO: initializing ciphers... aes-128-gcm
 2018-04-09 19:49:23 INFO: using nameserver: 1.1.1.1
 2018-04-09 19:49:23 INFO: tcp server listening at 127.0.0.1:45885
 2018-04-09 19:49:23 INFO: running from root user
2018/04/09 19:49:23 localHost=127.0.0.1, localPort=***, remoteHost=***, remotePort=443, configPath=/etc/shadowsocks-libev/gqserver.json
2018/04/09 19:49:23 Listening on ***.***.***.***:443
 2018-04-09 19:49:24 INFO: accept a connection
 2018-04-09 19:49:24 INFO: connect to ***.***.***.***:***
 2018-04-09 19:49:24 INFO: remote connected
 2018-04-09 19:49:37 INFO: accept a connection
...

And then, you can check your configuration by the outputs.

Something you may know is that this customized binary should not run in production.


customized gq-server based on 27fac11

@kaliiosto
Copy link

Hi,
If you get # error plugin service exit unexpectedly
please disable autostart shadowsocks-libev
sudo systemctl disable shadowsocks-libev
and reboot your droplet. After that try run manually
sudo ss-server -c /etc/shadowsocks-libev/config.json --plugin gq-server --plugin-opts "gqserver.json"
Before
image
After
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants