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

panic when ws server address not set #229

Closed
669800 opened this issue Feb 13, 2021 · 6 comments
Closed

panic when ws server address not set #229

669800 opened this issue Feb 13, 2021 · 6 comments

Comments

@669800
Copy link

669800 commented Feb 13, 2021

How to use trojan with Websocket at the same time.
How to write client and server config?
** tls://host:port[?skipVerify=true],ws://[@/path[?host=HOST]],trojan://pass@host:port?cert=PATH&key=PATH[&fallback=127.0.0.1]
**

@nadoo
Copy link
Owner

nadoo commented Feb 13, 2021

something like:

server:

glider -verbose -listen "tls://:PORT?cert=PATH&key=PATH,ws://@?host=HOST,trojanc://PASS"

note: trojanc is trojan without tls.

client:

glider -verbose -listen :8443 -forward "tls://HOST:PORT,ws://@?host=HOST,trojanc://PASS"

@nadoo nadoo added the question label Feb 13, 2021
@669800
Copy link
Author

669800 commented Feb 13, 2021

something like:

server:

glider -verbose -listen "tls://:PORT?cert=PATH&key=PATH,ws://@?host=HOST,trojanc://PASS"

note: trojanc is trojan without tls.

client:

glider -verbose -listen :8443 -forward "tls://HOST:PORT,ws://@?host=HOST,trojanc://PASS"

glider -verbose -listen "tls://:443?cert=/home/q.cer&key=/home/q.key,ws://@?host=nngm.xyz,trojanc://130987"

2021/02/13 17:53:20 group.go:182: [group] only 1 forwarder found, disable health checking
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x718c6d]

goroutine 1 [running]:
github.com/nadoo/glider/proxy/ws.NewWS(0x7fffd816c6aa, 0x14, 0x0, 0x0, 0x84cda0, 0xc000082460, 0xc000051400, 0x1, 0x1)
/home/runner/work/glider/glider/proxy/ws/ws.go:41 +0x34d
github.com/nadoo/glider/proxy/ws.NewWSServer(0x7fffd816c6aa, 0x14, 0x84cda0, 0xc000082460, 0xc0000ba170, 0x1, 0x0, 0xc0000c7c38)
/home/runner/work/glider/glider/proxy/ws/server.go:23 +0xb9
github.com/nadoo/glider/proxy.ServerFromURL(0x7fffd816c6aa, 0x14, 0x84cda0, 0xc000082460, 0xc000062ed0, 0x2, 0x2, 0x7ae000)
/home/runner/work/glider/glider/proxy/server.go:44 +0x21c
github.com/nadoo/glider/proxy/tls.NewTLSServer(0x7fffd816c67e, 0x51, 0x84cda0, 0xc000082460, 0xc0000ba0a0, 0x1, 0x0, 0xc0000c7e20)
/home/runner/work/glider/glider/proxy/tls/tls.go:109 +0x456
github.com/nadoo/glider/proxy.ServerFromURL(0x7fffd816c67e, 0x51, 0x84cda0, 0xc000082460, 0x0, 0x0, 0x0, 0xc000082460)
/home/runner/work/glider/glider/proxy/server.go:44 +0x21c
main.main()
/home/runner/work/glider/glider/main.go:71 +0x16b

@nadoo nadoo added the bug label Feb 14, 2021
@nadoo
Copy link
Owner

nadoo commented Feb 14, 2021

There's a bug in ws server, you can try the following to bypass it:
server:

glider -verbose -listen "tls://:PORT?cert=PATH&key=PATH,ws://HOST:PORT,trojanc://PASS"

note: ws://HOST:PORT

client:

glider -verbose -listen :8443 -forward "tls://HOST:PORT,ws://@?host=HOST,trojanc://PASS"

@nadoo
Copy link
Owner

nadoo commented Feb 14, 2021

and you'b better use nginx to handle tls and forward ws to glider:
nginx

server {
       listen 443 ssl;
       server_name HOST;

       ssl_protocols TLSv1.3;
       #ssl_protocols TLSv1.2 TLSv1.3;
       ssl_certificate PATH_CERT;
       ssl_certificate_key PATH_KEY;
       ssl_stapling on;
       ssl_stapling_verify on;
       ssl_trusted_certificate PATH_CERT;

       root PATH_ROOT;
       index index.html;

       location / {
               try_files $uri $uri/ =404;
       }

       location /ws {
            proxy_redirect off;
            proxy_pass http://127.0.0.1:50000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $http_host;

            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       }

}

server:

glider -verbose -listen "ws://127.0.0.1:50000,trojanc://PASS"

client:

glider -verbose -listen :8443 -forward "tls://HOST,ws:///ws,trojanc://PASS@"

@nadoo nadoo changed the title Question panic when ws server address not set Feb 14, 2021
@669800
Copy link
Author

669800 commented Feb 14, 2021

and you'b better use nginx to handle tls and forward ws to glider:
nginx

server {
       listen 443 ssl;
       server_name HOST;

       ssl_protocols TLSv1.3;
       #ssl_protocols TLSv1.2 TLSv1.3;
       ssl_certificate PATH_CERT;
       ssl_certificate_key PATH_KEY;
       ssl_stapling on;
       ssl_stapling_verify on;
       ssl_trusted_certificate PATH_CERT;

       root PATH_ROOT;
       index index.html;

       location / {
               try_files $uri $uri/ =404;
       }

       location /ws {
            proxy_redirect off;
            proxy_pass http://127.0.0.1:50000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $http_host;

            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       }

}

server:

glider -verbose -listen "ws://127.0.0.1:50000,trojanc://PASS"

client:

glider -verbose -listen :8443 -forward "tls://HOST,ws:///ws,trojanc://PASS@"

trojanc://PASS@?fallback=127.0.0.1------------------skipVerify=true??

@nadoo nadoo closed this as completed Feb 19, 2021
@qqqqqqrrrrhh123a
Copy link

i have same ws issues,help me #270

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

No branches or pull requests

3 participants