Giter Club home page Giter Club logo

bridge's Introduction

Bridge

Bridge is a TCP proxy tool Support http(s)-connect socks4/4a/5/5h ssh proxycommand

Build Go Report Card GoDoc Docker Automated build GitHub license

Supported protocols

Example

Mapping example.org:80 TCP port to 8080 port of the local machines.

bridge -b :8080 -p example.org:80
# `curl -H 'Host: example.org' 127.0.0.1:8080` will return to the target page

Proxy that can go through various protocols.

bridge -b :8080 -p example.org:80 -p ssh://username:password@my_server:22
bridge -b :8080 -p example.org:80 -p ssh://username@my_server:22?identity_file=~/.ssh/id_rsa
bridge -b :8080 -p example.org:80 -p socks5://username:password@my_server:1080
bridge -b :8080 -p example.org:80 -p http://username:password@my_server:8080
bridge -b :8080 -p example.org:80 -p 'cmd:nc %h %p'
bridge -b :8080 -p example.org:80 -p 'cmd:ssh sshserver nc %h %p'

It can also go through multi-level proxy.

bridge -b :8080 -p example.org:80 -p http://username:password@my_server2:8080 -p http://username:password@my_server1:8080

Using proxy protocol(http/socks4/socks5) instead of direct TCP forwarding.

bridge -b :8080 -p -
bridge -b :8080 -p - -p http://username:password@my_server1:8080
# `http_proxy=http://127.0.0.1:8080 curl example.org` Will be the proxy

You can also use ssh to listen for port mapping from local port to server port,
due to the limitation of sshd, only 127.0.0.1 ports can be monitored.
if you want to provide external services,
you need to change the 'GatewayPorts no' in /etc/ssh/sshd_config to yes
and then reload sshd.

bridge -b :8080 -b ssh://username:password@my_server:22 -p 127.0.0.1:80

More of the time I'm acting as a ssh proxy.

# in ~/.ssh/config
ProxyCommand bridge -p %h:%p -p "ssh://username@my_server?identity_file=~/.ssh/id_rsa"

Usage

Usage: bridge [-d] \
	[-b=[[tcp://]bind_address]:bind_port \
	[-b=ssh://bridge_bind_address:bridge_bind_port [-b=(socks4://|socks4a://|socks5://|socks5h://|https://|http://|ssh://|cmd:)bridge_bind_address:bridge_bind_port ...]]] \ // 
	-p=([tcp://]proxy_address:proxy_port|-) \
	[-p=(socks4://|socks4a://|socks5://|socks5h://|https://|http://|ssh://|cmd:)bridge_proxy_address:bridge_proxy_port ...]
  -b, --bind strings    The first is the listening address, and then the proxy through which the listening address passes.
                        If it is not filled in, it is redirected to the pipeline.
                        only SSH and local support listening, so the last proxy must be ssh.
  -d, --debug           Output the communication data.
  -p, --proxy strings   The first is the dial-up address, followed by the proxy through which the dial-up address passes.

Install

go get -u -v github.com/wzshiming/bridge/cmd/bridge

or

Download releases

or

Image

License

Licensed under the MIT License. See LICENSE for the full license text.

bridge's People

Contributors

dependabot[bot] avatar wzshiming avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bridge's Issues

Question about tool usage.

Hi,

I want to use this tool to produce a socks5 to http-proxy connection.
In detail, I want to spawn a socks5 server on my device where a client application can connect to.
My device is behind a corporate proxy which has basic authentication, so I also have to provide that, so the application can talk to a website on the internet.

I tried several command variants, but it always states:
err="dial http: unknown network http" or err="dial http: unknown network socks5".

Do you have a proposal of what I could try, to get this up and running?
Also, it would help, to have some example usages for common use cases on the README or in the wiki.

Thanks in advance!!
Best regards,
Dan

登录shell 终端后累计 两次 `ctl+c` 直接退出了,是否需要优化 bridge 对信号量的处理?

测试1:

执行 ssh -o "ProxyCommand=./bridge-win64.bin -p %h:%p -p socks5://xx:xx@ip:xxx "xxxx@xxxxx 登录shell 终端后 两次 ctl+c 直接退出了,是否需要优化 bridge 对信号量的处理?

测试2: 配置在 ~/.ssh/conf 同样问题

测试3:在 vscode 的 Read more about SSH config files 没有问题

测试4:使用 corkscrew 是没有问题的

ProxyCommand corkscrew.exe localhost 10805 %h %p

How to compile Bridge with gccgo?

When I try to compile Bridge with gccgo I get the following error:


me@localhost:/tmp/bridge/cmd/bridge$ go build -compiler=gccgo
/home/me/go/pkg/mod/golang.org/x/[email protected]/curve25519/curve25519_go120.go:9:8: package crypto/ecdh is not in std (/usr/lib/go-1.22/src/crypto/ecdh)
../../logger/logger.go:5:2: package log/slog is not in std (/usr/lib/go-1.22/src/log/slog)

The folders /usr/lib/go-1.22/src/crypto/ecdh and /usr/lib/go-1.22/src/log/slog does exist:

me@localhost:/tmp/bridge/cmd/bridge$ ls /usr/lib/go-1.22/src/crypto/ecdh
ecdh.go  ecdh_test.go  nist.go  x25519.go

me@localhost:/tmp/bridge/cmd/bridge$ ls /usr/lib/go-1.22/src/log/slog
attr.go                           example_wrap_test.go  logger_test.go
attr_test.go                      handler.go            record.go
doc.go                            handler_test.go       record_test.go
example_custom_levels_test.go     internal              slogtest_test.go
example_level_handler_test.go     json_handler.go       text_handler.go
example_log_level_test.go         json_handler_test.go  text_handler_test.go
example_logvaluer_group_test.go   level.go              value_access_benchmark_test.go
example_logvaluer_secret_test.go  level_test.go         value.go
example_test.go                   logger.go             value_test.go

How can I fix this?

Assigning multiple proxies for a rule

Thanks for the useful program, this is very cool!

Is it possible to configure multiple proxies for a route? Maybe something like
bridge -b :8080 -p - -p socks5://server1:1080,socks5://server2:1080,socks5://server3:1080
where it would be either random or round-robin.

There are actually several use-cases I could see here, from geo-based endpoint monitoring to load-balancing when using multi-slot downloaders like axel.

Multiple platform support via Appimage ?

Hi
So the setup and usage look quite easy. I do wonder, has having multiple package.. perhaps having a .appimage can be helpfull ? Also, that will make possible to run it in Centos 7.
thanks , great project.

Multiple proxy fails "first path segment in URL cannot contain colon"

When i am using single proxy its work perfectly

bridge -b :123 -p tcp://127.0.0.1:2080

but with multiple tcp proxy

 bridge -b :123 -p tcp://127.0.0.1:2080 -p tcp://127.0.0.1:2070
2024/03/15 21:28:28 INFO DIAL "tcp://127.0.0.1:2080" <- "tcp://127.0.0.1:2070" <- LOCAL <-
 "tcp://:123" LISTEN
 chains="{Bind:[{Probe: LB:[:123]}] Proxy:[{Probe: LB:[tcp://127.0.0.1:2080]} {Probe: LB:[
tcp://127.0.0.1:2070]}] IdleTimeout:0s}"
2024/03/15 21:28:28 ERROR BridgeWithConfig chains="{Bind:[{Probe: LB:[:123]}] Proxy:[{Prob
e: LB:[tcp://127.0.0.1:2080]} {Probe: LB:[tcp://127.0.0.1:2070]}] IdleTimeout:0s}" err="la
st scheme \"tcp\" not supported: invalid scheme"

or multiple socks5 proxy

bridge -b :123 -p socks://127.0.0.1:2080 -p socks5://127.0.0.1:2070
2024/03/15 21:29:41 INFO DIAL "socks://127.0.0.1:2080" <- "socks5://127.0.0.1:2070" <- LOC
AL <- "tcp://:123" LISTEN
 chains="{Bind:[{Probe: LB:[:123]}] Proxy:[{Probe: LB:[socks://127.0.0.1:2080]} {Probe: LB
:[socks5://127.0.0.1:2070]}] IdleTimeout:0s}"
2024/03/15 21:29:41 INFO Connect chains="{Bind:[{Probe: LB:[:123]}] Proxy:[{Probe: LB:[soc
ks://127.0.0.1:2080]} {Probe: LB:[socks5://127.0.0.1:2070]}] IdleTimeout:0s}" remote_addre
ss=127.0.0.1:26402
2024/03/15 21:29:41 ERROR Step chains="{Bind:[{Probe: LB:[:123]}] Proxy:[{Probe: LB:[socks
://127.0.0.1:2080]} {Probe: LB:[socks5://127.0.0.1:2070]}] IdleTimeout:0s}" err="unsupport
ed network \"socks\""
...

without proxy schema (tcp):

bridge -b :123 -p 127.0.0.1:2080 -p 127.0.0.1:2070
2024/03/15 21:30:52 INFO DIAL "tcp://127.0.0.1:2080" <- "tcp://127.0.0.1:2070" <- LOCAL <-
 "tcp://:123" LISTEN
 chains="{Bind:[{Probe: LB:[:123]}] Proxy:[{Probe: LB:[127.0.0.1:2080]} {Probe: LB:[127.0.
0.1:2070]}] IdleTimeout:0s}"
2024/03/15 21:30:52 ERROR BridgeWithConfig chains="{Bind:[{Probe: LB:[:123]}] Proxy:[{Prob
e: LB:[127.0.0.1:2080]} {Probe: LB:[127.0.0.1:2070]}] IdleTimeout:0s}" err="parse \"127.0.
0.1:2070\": first path segment in URL cannot contain colon"

Am i wrong with commands?
(using windows 386 bin)

HTTPS to SOCKS5 binding

Hello,

Thanks for such a great project.

Is it possible to bind a http/https proxy to a socks5 proxy? It's useful when application supports only a http/https proxy, but you have only a socks5 proxy.

typo in project description

Birdge is a multi-level proxy that supports clients and servers with multiple protocols. SSHProxy/HTTPProxy/Socks4/Socks5/Shadowsocks

Birdge -> Bridge

also, i would replace the last part with: SSHProxy, HTTPProxy, Socks4, Socks5, Shadowsocks
to avoid broken words from line-wrapping

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.