xsank / easyproxy Goto Github PK
View Code? Open in Web Editor NEWMake tcp proxy easy to use.
Home Page: http://xsank.com/EasyProxy/
License: MIT License
Make tcp proxy easy to use.
Home Page: http://xsank.com/EasyProxy/
License: MIT License
您好,这个工程的主要功能,使用场景还有如何使用的能描述下么,谢谢
TODO:
我是用这个来代理连接到svn服务器,比如svn://localhost:9999,启动proxy后,连接不过去,后台还保持了好几个连接到背后的svn服务器,可能是我通过9999端口访问的时候关掉了,
1.但是proxy与svn之间的连接没断开。
2.ctrl+c 关不掉程序
3.svn协议的不行?
Its a bit unclear how to set multpile services and hosts in config file. Can you give example for it. Thx.
func (proxy *EasyProxy) Dispatch(conn net.Conn) {
if proxy.isBackendAvailable() {
servers := proxy.data.BackendUrls()
// 这里不是特别懂,为啥选出这个url呢?
url := proxy.strategy.Choose(conn.RemoteAddr().String(), servers)
proxy.transfer(conn, url)
} else {
conn.Close()
log.Println("no backend available now,please check your server!")
}
}
func (proxy *EasyProxy) transfer(local net.Conn, remote string) {
remoteConn, err := net.DialTimeout("tcp", remote, DefaultTimeOut*time.Second)
if err != nil {
local.Close()
proxy.Clean(remote)
log.Println("connect backend err", err)
return
}
sync := make(chan int)
channel := &structure.Channel{Src: local, Dst: remoteConn}
go proxy.putChannel(channel)
go proxy.safeCopy(local, remoteConn, sync)
go proxy.safeCopy(remoteConn, local, sync)
go proxy.closeChannel(channel, sync)
}
我的理解,proxy.strategy.Choose 会在backend随机选择一个对应的backend server来做连接,为啥这里strategy是随机的,不是应该和conn对应对应的吗? 谢谢大佬帮忙解答一下
Both ChannelManager and ProxyData are multi-threads unsafe, so why not protect those append or delete operations to the same slice or map from different goroutines with sync.Mutex?
remoteConn, err := net.DialTimeout("tcp", remote, DefaultTimeoutTime * time.Second)
if err != nil {
local.Close()
proxy.Clean(remote)
log.Println("connect backend error:%s", err)
return
}
sync := make(chan int, 1)
channel := structure.Channel{SrcConn:local, DstConn:remoteConn}
go proxy.putChannel(&channel)
go proxy.safeCopy(local, remoteConn, sync)
go proxy.safeCopy(remoteConn, local, sync)
go proxy.closeChannel(&channel, sync)
panic: runtime error: integer divide by zero
[signal 0x8 code=0x1 addr=0x5b9d29 pc=0x5b9d29]
goroutine 9 [running]:
panic(0x7c8020, 0xc82000a0f0)
/usr/lib/golang/src/runtime/panic.go:481 +0x3e6
github.com/xsank/EasyProxy/src/proxy/schedule.(*Poll).Choose(0xc82000b260, 0xc82000bfd0, 0xf, 0xa7ce70, 0x0, 0x0, 0xc8200118c0, 0xc820011800)
/vagrant/.gopath/src/github.com/xsank/EasyProxy/src/proxy/schedule/poll.go:12 +0x49
github.com/xsank/EasyProxy/src/proxy.(*EasyProxy).Dispatch(0xc8200aca00, 0x7f00e89faa70, 0xc820022088)
/vagrant/.gopath/src/github.com/xsank/EasyProxy/src/proxy/esay_proxy.go:64 +0x11c
created by github.com/xsank/EasyProxy/src/gateway.(*ProxyServer).Start
/vagrant/.gopath/src/github.com/xsank/EasyProxy/src/gateway/server.go:46 +0x3ed
exit status 2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.