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

How to use with piping-server http basic auth? #19

Open
m2acgi opened this issue Oct 21, 2022 · 16 comments
Open

How to use with piping-server http basic auth? #19

m2acgi opened this issue Oct 21, 2022 · 16 comments

Comments

@m2acgi
Copy link

m2acgi commented Oct 21, 2022

How to use with piping-server http basic auth? Thanks.

@nwtgck
Copy link
Owner

nwtgck commented May 27, 2023

You can use -H option to specify HTTP header. e.g. -H "Authorization: Basic am9objoxMjM0"

@m2acgi m2acgi closed this as completed May 29, 2023
@m2acgi
Copy link
Author

m2acgi commented May 28, 2024

Not work, it says ↑ 0B ( 0B/s) | ↓ 0B ( 0B/s)2024/05/28 09:45:30 [ERR] yamux: Failed to read header: invalid content-type: , test on Windows 10 + go-piping-tunnel v0.11.0

@m2acgi m2acgi reopened this May 28, 2024
@nwtgck
Copy link
Owner

nwtgck commented May 28, 2024

Did you use only piping-tunnel on both server-host and client-host or a different tool?

@m2acgi
Copy link
Author

m2acgi commented May 29, 2024

Both server and client are piping-tunnel

@nwtgck
Copy link
Owner

nwtgck commented May 29, 2024

I tried it but it worked.

edit: I may drop Content-Type checking in yamux.

return nil, errors.Errorf("invalid content-type: %s", contentType)

@m2acgi
Copy link
Author

m2acgi commented May 29, 2024

In my environment, the piping server is behind the Caddy reverse proxy server, the basic auth was provided by the Caddy server

@nwtgck
Copy link
Owner

nwtgck commented May 29, 2024

Does it work without --yamux flag?

I will release new version avoiding content-type checking.

@m2acgi
Copy link
Author

m2acgi commented May 29, 2024

The program exited directly after remove --yamux:

[root@almalinux9-test ~]# ./piping-tunnel server --port 22 -H "Authorization: Basic Z3Vlc3Q6MTIzNDU2" --server https://piping.example.com 1234 4321
[INFO] Hint: Client host (socat + curl)
  curl -NsS https://piping.example.com/4321 | socat TCP-LISTEN:31376 - | curl -NsST - https://piping.example.com/1234
[INFO] Hint: Client host (piping-tunnel)
  piping-tunnel -s https://piping.example.com client -p 31376 1234 4321
↑  0B ( 0B/s) | ↓  0B ( 0B/s)
[INFO] Finished
[root@almalinux9-test ~]#

@nwtgck
Copy link
Owner

nwtgck commented May 29, 2024

0.12.0 was released for avoiding "invalid content-type" error.
https://github.com/nwtgck/go-piping-tunnel/releases/tag/v0.12.0

@m2acgi
Copy link
Author

m2acgi commented May 30, 2024

piping-tunnel v0.12.0 server still not work:

server:

[root@almalinux9-test ~]# ./piping-tunnel server --port 22 --yamux -H "Authorization: Basic Z3Vlc3Q6MTIzNDU2" --server https://piping.example.com 1234 4321
[INFO] Hint: Client host (piping-tunnel)
  piping-tunnel -s https://piping.example.com client -p 31376 --yamux 1234 4321
[INFO] Multiplexing with hashicorp/yamux
↑  0B ( 0B/s) | ↓  0B ( 0B/s)[WARN] --yamux flag may be missing in client-host
Error: EOF

client:

root@debian-12-test:~# ./piping-tunnel client --port 2222 --yamux -H "Authorization: Basic Z3Vlc3Q6MTIzNDU2" --server https://piping.example.com 1234 4321
[INFO] Client host listening on 2222 ...
[INFO] Hint: Server host (piping-tunnel)
  piping-tunnel -s https://piping.example.com server -p <YOUR PORT> --yamux 1234 4321
    OR
  piping-tunnel -s https://piping.example.com socks --yamux 1234 4321
[INFO] Multiplexing with hashicorp/yamux
↑  0B ( 0B/s) | ↓  0B ( 0B/s)[INFO] --yamux flag may be missing in server-host

@nwtgck
Copy link
Owner

nwtgck commented May 30, 2024

Could you check the server supports data streaming? You can use curl like the following video:

piping-server-text-streaming-curl.mov
# sender
curl -T- https://ppng.io/mytext
# receiver
curl https://ppng.io/mytext

For the port forwarding, the server's streaming feature is necessary.

@m2acgi
Copy link
Author

m2acgi commented May 31, 2024

I've checked the feature data streaming after I deploy the piping-server to the prod env.

BTW: After disable the basic auth from Caddy server, the piping-tunnel works well without the -H arg.

@nwtgck
Copy link
Owner

nwtgck commented Jun 1, 2024

Have you tried -H flags with curl for streaming check?:

# sender
curl -H "Authorization: Basic ..." -T- https://your.server/mytext
# receiver
curl -H "Authorization: Basic ..." https://your.server/mytext

@m2acgi
Copy link
Author

m2acgi commented Jun 1, 2024

Have you tried -H flags with curl for streaming check?:

# sender
curl -H "Authorization: Basic ..." -T- https://your.server/mytext
# receiver
curl -H "Authorization: Basic ..." https://your.server/mytext

Work fine.

@nwtgck
Copy link
Owner

nwtgck commented Jun 1, 2024

Did curl -H "Authorization: ..." work with Basic-auth-enabled Caddy?

@m2acgi
Copy link
Author

m2acgi commented Jun 2, 2024

Did curl -H "Authorization: ..." work with Basic-auth-enabled Caddy?

Yes

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

2 participants