Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4214ec4239 | ||
|
|
504de47999 | ||
|
|
e185d734d0 | ||
|
|
9b1ef52649 | ||
|
|
5c9fc850d8 | ||
|
|
ff96e52a33 | ||
|
|
78004bcd39 | ||
|
|
b16decf976 | ||
|
|
828636553d | ||
|
|
bfcc27e70f | ||
|
|
7cb7d34d42 |
@ -1,4 +1,9 @@
|
|||||||
proxy更新日志
|
proxy更新日志
|
||||||
|
v4.9
|
||||||
|
1.修复了HTTP Basic代理返回不合适的头部,导致浏览器不会弹框,个别代理插件无法认证的问题.
|
||||||
|
2.内网穿透切换smux到yamux.
|
||||||
|
3.优化了HTTP(S)\SOCKS5代理--always的处理逻辑.
|
||||||
|
|
||||||
v4.8
|
v4.8
|
||||||
1.优化了SPS连接HTTP上级的指令,避免了某些代理不响应的问题.
|
1.优化了SPS连接HTTP上级的指令,避免了某些代理不响应的问题.
|
||||||
2.SPS功能增加了参数:
|
2.SPS功能增加了参数:
|
||||||
|
|||||||
@ -36,7 +36,9 @@ Proxy is a high performance HTTP, HTTPS, HTTPS, websocket, TCP, UDP, Socks5 prox
|
|||||||
- ...
|
- ...
|
||||||
|
|
||||||
|
|
||||||
This page is the v4.7 manual, and the other version of the manual can be checked by the following link.
|
This page is the v4.9 manual, and the other version of the manual can be checked by the following link.
|
||||||
|
- [v4.8 manual](https://github.com/snail007/goproxy/tree/v4.8)
|
||||||
|
- [v4.7 manual](https://github.com/snail007/goproxy/tree/v4.7)
|
||||||
- [v4.6 manual](https://github.com/snail007/goproxy/tree/v4.6)
|
- [v4.6 manual](https://github.com/snail007/goproxy/tree/v4.6)
|
||||||
- [v4.5 manual](https://github.com/snail007/goproxy/tree/v4.5)
|
- [v4.5 manual](https://github.com/snail007/goproxy/tree/v4.5)
|
||||||
- [v4.4 manual](https://github.com/snail007/goproxy/tree/v4.4)
|
- [v4.4 manual](https://github.com/snail007/goproxy/tree/v4.4)
|
||||||
@ -161,7 +163,7 @@ If the installation fails or your VPS is not a linux64 system, please follow the
|
|||||||
Download address: https://github.com/snail007/goproxy/releases
|
Download address: https://github.com/snail007/goproxy/releases
|
||||||
```shell
|
```shell
|
||||||
cd /root/proxy/
|
cd /root/proxy/
|
||||||
wget https://github.com/snail007/goproxy/releases/download/v4.8/proxy-linux-amd64.tar.gz
|
wget https://github.com/snail007/goproxy/releases/download/v4.9/proxy-linux-amd64.tar.gz
|
||||||
```
|
```
|
||||||
#### **2.Download the automatic installation script**
|
#### **2.Download the automatic installation script**
|
||||||
```shell
|
```shell
|
||||||
|
|||||||
@ -37,7 +37,9 @@ Proxy是golang实现的高性能http,https,websocket,tcp,udp,socks5代理服务
|
|||||||
- ...
|
- ...
|
||||||
|
|
||||||
|
|
||||||
本页是v4.7手册,其他版本手册请点击下面链接查看.
|
本页是v4.9手册,其他版本手册请点击下面链接查看.
|
||||||
|
- [v4.8手册](https://github.com/snail007/goproxy/tree/v4.8)
|
||||||
|
- [v4.7手册](https://github.com/snail007/goproxy/tree/v4.7)
|
||||||
- [v4.6手册](https://github.com/snail007/goproxy/tree/v4.6)
|
- [v4.6手册](https://github.com/snail007/goproxy/tree/v4.6)
|
||||||
- [v4.5手册](https://github.com/snail007/goproxy/tree/v4.5)
|
- [v4.5手册](https://github.com/snail007/goproxy/tree/v4.5)
|
||||||
- [v4.4手册](https://github.com/snail007/goproxy/tree/v4.4)
|
- [v4.4手册](https://github.com/snail007/goproxy/tree/v4.4)
|
||||||
@ -160,7 +162,7 @@ curl -L https://raw.githubusercontent.com/snail007/goproxy/master/install_auto.s
|
|||||||
下载地址:https://github.com/snail007/goproxy/releases
|
下载地址:https://github.com/snail007/goproxy/releases
|
||||||
```shell
|
```shell
|
||||||
cd /root/proxy/
|
cd /root/proxy/
|
||||||
wget https://github.com/snail007/goproxy/releases/download/v4.8/proxy-linux-amd64.tar.gz
|
wget https://github.com/snail007/goproxy/releases/download/v4.9/proxy-linux-amd64.tar.gz
|
||||||
```
|
```
|
||||||
#### **2.下载自动安装脚本**
|
#### **2.下载自动安装脚本**
|
||||||
```shell
|
```shell
|
||||||
|
|||||||
@ -5,7 +5,7 @@ if [ -e /tmp/proxy ]; then
|
|||||||
fi
|
fi
|
||||||
mkdir /tmp/proxy
|
mkdir /tmp/proxy
|
||||||
cd /tmp/proxy
|
cd /tmp/proxy
|
||||||
wget https://github.com/snail007/goproxy/releases/download/v4.8/proxy-linux-amd64.tar.gz
|
wget https://github.com/snail007/goproxy/releases/download/v4.9/proxy-linux-amd64.tar.gz
|
||||||
|
|
||||||
# #install proxy
|
# #install proxy
|
||||||
tar zxvf proxy-linux-amd64.tar.gz
|
tar zxvf proxy-linux-amd64.tar.gz
|
||||||
|
|||||||
2
main.go
2
main.go
@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/snail007/goproxy/services"
|
"github.com/snail007/goproxy/services"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VERSION = "4.8"
|
const APP_VERSION = "4.9"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
err := initConfig()
|
err := initConfig()
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
VER="4.8"
|
VER="4.9"
|
||||||
RELEASE="release-${VER}"
|
RELEASE="release-${VER}"
|
||||||
rm -rf .cert
|
rm -rf .cert
|
||||||
mkdir .cert
|
mkdir .cert
|
||||||
|
|||||||
@ -238,13 +238,8 @@ func Start(serviceID, serviceArgsStr string) (errStr string) {
|
|||||||
spsArgs.ParentKey = sps.Flag("parent-key", "the password for auto encrypt/decrypt parent connection data").Short('Z').Default("").String()
|
spsArgs.ParentKey = sps.Flag("parent-key", "the password for auto encrypt/decrypt parent connection data").Short('Z').Default("").String()
|
||||||
spsArgs.LocalCompress = sps.Flag("local-compress", "auto compress/decompress data on local connection").Short('m').Default("false").Bool()
|
spsArgs.LocalCompress = sps.Flag("local-compress", "auto compress/decompress data on local connection").Short('m').Default("false").Bool()
|
||||||
spsArgs.ParentCompress = sps.Flag("parent-compress", "auto compress/decompress data on parent connection").Short('M').Default("false").Bool()
|
spsArgs.ParentCompress = sps.Flag("parent-compress", "auto compress/decompress data on parent connection").Short('M').Default("false").Bool()
|
||||||
spsArgs.SSMethod = sps.Flag("ss-method", "").Hidden().Short('h').Default("aes-256-cfb").String()
|
|
||||||
spsArgs.SSKey = sps.Flag("ss-key", "").Hidden().Short('j').Default("sspassword").String()
|
|
||||||
spsArgs.ParentSSMethod = sps.Flag("parent-ss-method", "").Hidden().Short('H').Default("aes-256-cfb").String()
|
|
||||||
spsArgs.ParentSSKey = sps.Flag("parent-ss-key", "").Hidden().Short('J').Default("sspassword").String()
|
|
||||||
spsArgs.DisableHTTP = sps.Flag("disable-http", "disable http(s) proxy").Default("false").Bool()
|
spsArgs.DisableHTTP = sps.Flag("disable-http", "disable http(s) proxy").Default("false").Bool()
|
||||||
spsArgs.DisableSocks5 = sps.Flag("disable-socks", "disable socks proxy").Default("false").Bool()
|
spsArgs.DisableSocks5 = sps.Flag("disable-socks", "disable socks proxy").Default("false").Bool()
|
||||||
spsArgs.DisableSS = sps.Flag("disable-ss", "").Hidden().Default("false").Bool()
|
|
||||||
|
|
||||||
//parse args
|
//parse args
|
||||||
_args := strings.Fields(strings.Trim(serviceArgsStr, " "))
|
_args := strings.Fields(strings.Trim(serviceArgsStr, " "))
|
||||||
|
|||||||
@ -229,7 +229,7 @@ func (s *HTTP) callback(inConn net.Conn) {
|
|||||||
address := req.Host
|
address := req.Host
|
||||||
host, _, _ := net.SplitHostPort(address)
|
host, _, _ := net.SplitHostPort(address)
|
||||||
useProxy := false
|
useProxy := false
|
||||||
if !utils.IsIternalIP(host) {
|
if !utils.IsIternalIP(host, *s.cfg.Always) {
|
||||||
useProxy = true
|
useProxy = true
|
||||||
if *s.cfg.Parent == "" {
|
if *s.cfg.Parent == "" {
|
||||||
useProxy = false
|
useProxy = false
|
||||||
|
|||||||
@ -14,7 +14,8 @@ import (
|
|||||||
|
|
||||||
"github.com/snail007/goproxy/utils"
|
"github.com/snail007/goproxy/utils"
|
||||||
|
|
||||||
"github.com/xtaci/smux"
|
//"github.com/xtaci/smux"
|
||||||
|
smux "github.com/hashicorp/yamux"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MuxBridge struct {
|
type MuxBridge struct {
|
||||||
@ -250,9 +251,9 @@ func (s *MuxBridge) callback(inConn net.Conn, serverID, key string) {
|
|||||||
index := keys[i]
|
index := keys[i]
|
||||||
s.log.Printf("select client : %s-%s", key, index)
|
s.log.Printf("select client : %s-%s", key, index)
|
||||||
session, _ := group.Get(index)
|
session, _ := group.Get(index)
|
||||||
session.(*smux.Session).SetDeadline(time.Now().Add(time.Millisecond * time.Duration(*s.cfg.Timeout)))
|
//session.(*smux.Session).SetDeadline(time.Now().Add(time.Millisecond * time.Duration(*s.cfg.Timeout)))
|
||||||
stream, err := session.(*smux.Session).OpenStream()
|
stream, err := session.(*smux.Session).OpenStream()
|
||||||
session.(*smux.Session).SetDeadline(time.Time{})
|
//session.(*smux.Session).SetDeadline(time.Time{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log.Printf("%s client session open stream %s fail, err: %s, retrying...", key, serverID, err)
|
s.log.Printf("%s client session open stream %s fail, err: %s, retrying...", key, serverID, err)
|
||||||
time.Sleep(time.Second * 3)
|
time.Sleep(time.Second * 3)
|
||||||
|
|||||||
@ -11,7 +11,8 @@ import (
|
|||||||
"github.com/snail007/goproxy/utils"
|
"github.com/snail007/goproxy/utils"
|
||||||
|
|
||||||
"github.com/golang/snappy"
|
"github.com/golang/snappy"
|
||||||
"github.com/xtaci/smux"
|
//"github.com/xtaci/smux"
|
||||||
|
smux "github.com/hashicorp/yamux"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MuxClient struct {
|
type MuxClient struct {
|
||||||
|
|||||||
@ -15,7 +15,8 @@ import (
|
|||||||
"github.com/snail007/goproxy/utils"
|
"github.com/snail007/goproxy/utils"
|
||||||
|
|
||||||
"github.com/golang/snappy"
|
"github.com/golang/snappy"
|
||||||
"github.com/xtaci/smux"
|
//"github.com/xtaci/smux"
|
||||||
|
smux "github.com/hashicorp/yamux"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MuxServer struct {
|
type MuxServer struct {
|
||||||
|
|||||||
@ -519,7 +519,7 @@ func (s *Socks) proxyTCP(inConn *net.Conn, methodReq socks.MethodsRequest, reque
|
|||||||
if *s.cfg.Parent != "" {
|
if *s.cfg.Parent != "" {
|
||||||
host, _, _ := net.SplitHostPort(request.Addr())
|
host, _, _ := net.SplitHostPort(request.Addr())
|
||||||
useProxy := false
|
useProxy := false
|
||||||
if utils.IsIternalIP(host) {
|
if utils.IsIternalIP(host, *s.cfg.Always) {
|
||||||
useProxy = false
|
useProxy = false
|
||||||
} else {
|
} else {
|
||||||
k := s.Resolve(request.Addr())
|
k := s.Resolve(request.Addr())
|
||||||
@ -559,6 +559,7 @@ func (s *Socks) proxyTCP(inConn *net.Conn, methodReq socks.MethodsRequest, reque
|
|||||||
s.log.Printf("conn %s - %s connected", inAddr, request.Addr())
|
s.log.Printf("conn %s - %s connected", inAddr, request.Addr())
|
||||||
utils.IoBind(*inConn, outConn, func(err interface{}) {
|
utils.IoBind(*inConn, outConn, func(err interface{}) {
|
||||||
s.log.Printf("conn %s - %s released", inAddr, request.Addr())
|
s.log.Printf("conn %s - %s released", inAddr, request.Addr())
|
||||||
|
s.userConns.Remove(inAddr)
|
||||||
}, s.log)
|
}, s.log)
|
||||||
if c, ok := s.userConns.Get(inAddr); ok {
|
if c, ok := s.userConns.Get(inAddr); ok {
|
||||||
(*c.(*net.Conn)).Close()
|
(*c.(*net.Conn)).Close()
|
||||||
|
|||||||
@ -5,12 +5,14 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
logger "log"
|
logger "log"
|
||||||
"net"
|
"net"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/snail007/goproxy/utils"
|
"github.com/snail007/goproxy/utils"
|
||||||
|
|
||||||
"github.com/xtaci/smux"
|
//"github.com/xtaci/smux"
|
||||||
|
smux "github.com/hashicorp/yamux"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ServerConn struct {
|
type ServerConn struct {
|
||||||
@ -89,10 +91,12 @@ func (s *TunnelBridge) callback(inConn net.Conn) {
|
|||||||
var err error
|
var err error
|
||||||
//s.log.Printf("connection from %s ", inConn.RemoteAddr())
|
//s.log.Printf("connection from %s ", inConn.RemoteAddr())
|
||||||
sess, err := smux.Server(inConn, &smux.Config{
|
sess, err := smux.Server(inConn, &smux.Config{
|
||||||
KeepAliveInterval: 10 * time.Second,
|
AcceptBacklog: 256,
|
||||||
KeepAliveTimeout: time.Duration(*s.cfg.Timeout) * time.Second,
|
EnableKeepAlive: true,
|
||||||
MaxFrameSize: 4096,
|
KeepAliveInterval: 9 * time.Second,
|
||||||
MaxReceiveBuffer: 4194304,
|
ConnectionWriteTimeout: 3 * time.Second,
|
||||||
|
MaxStreamWindowSize: 512 * 1024,
|
||||||
|
LogOutput: os.Stderr,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log.Printf("new mux server conn error,ERR:%s", err)
|
s.log.Printf("new mux server conn error,ERR:%s", err)
|
||||||
|
|||||||
@ -6,11 +6,13 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
logger "log"
|
logger "log"
|
||||||
"net"
|
"net"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/snail007/goproxy/utils"
|
"github.com/snail007/goproxy/utils"
|
||||||
|
|
||||||
"github.com/xtaci/smux"
|
//"github.com/xtaci/smux"
|
||||||
|
smux "github.com/hashicorp/yamux"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TunnelClient struct {
|
type TunnelClient struct {
|
||||||
@ -139,10 +141,12 @@ func (s *TunnelClient) GetConn() (conn net.Conn, err error) {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
conn = net.Conn(&_conn)
|
conn = net.Conn(&_conn)
|
||||||
c, e := smux.Client(conn, &smux.Config{
|
c, e := smux.Client(conn, &smux.Config{
|
||||||
KeepAliveInterval: 10 * time.Second,
|
AcceptBacklog: 256,
|
||||||
KeepAliveTimeout: time.Duration(*s.cfg.Timeout) * time.Second,
|
EnableKeepAlive: true,
|
||||||
MaxFrameSize: 4096,
|
KeepAliveInterval: 9 * time.Second,
|
||||||
MaxReceiveBuffer: 4194304,
|
ConnectionWriteTimeout: 3 * time.Second,
|
||||||
|
MaxStreamWindowSize: 512 * 1024,
|
||||||
|
LogOutput: os.Stderr,
|
||||||
})
|
})
|
||||||
if e != nil {
|
if e != nil {
|
||||||
s.log.Printf("new mux client conn error,ERR:%s", e)
|
s.log.Printf("new mux client conn error,ERR:%s", e)
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
logger "log"
|
logger "log"
|
||||||
"net"
|
"net"
|
||||||
|
"os"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -13,7 +14,8 @@ import (
|
|||||||
|
|
||||||
"github.com/snail007/goproxy/utils"
|
"github.com/snail007/goproxy/utils"
|
||||||
|
|
||||||
"github.com/xtaci/smux"
|
//"github.com/xtaci/smux"
|
||||||
|
smux "github.com/hashicorp/yamux"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TunnelServer struct {
|
type TunnelServer struct {
|
||||||
@ -288,10 +290,12 @@ func (s *TunnelServer) GetConn() (conn net.Conn, err error) {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
conn = net.Conn(&_conn)
|
conn = net.Conn(&_conn)
|
||||||
c, e := smux.Client(conn, &smux.Config{
|
c, e := smux.Client(conn, &smux.Config{
|
||||||
KeepAliveInterval: 10 * time.Second,
|
AcceptBacklog: 256,
|
||||||
KeepAliveTimeout: time.Duration(*s.cfg.Timeout) * time.Second,
|
EnableKeepAlive: true,
|
||||||
MaxFrameSize: 4096,
|
KeepAliveInterval: 9 * time.Second,
|
||||||
MaxReceiveBuffer: 4194304,
|
ConnectionWriteTimeout: 3 * time.Second,
|
||||||
|
MaxStreamWindowSize: 512 * 1024,
|
||||||
|
LogOutput: os.Stderr,
|
||||||
})
|
})
|
||||||
if e != nil {
|
if e != nil {
|
||||||
s.log.Printf("new mux client conn error,ERR:%s", e)
|
s.log.Printf("new mux client conn error,ERR:%s", e)
|
||||||
|
|||||||
@ -579,9 +579,23 @@ func HttpGet(URL string, timeout int, host ...string) (body []byte, code int, er
|
|||||||
body, err = ioutil.ReadAll(resp.Body)
|
body, err = ioutil.ReadAll(resp.Body)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
func IsIternalIP(domainOrIP string) bool {
|
func IsIternalIP(domainOrIP string, always bool) bool {
|
||||||
var outIPs []net.IP
|
var outIPs []net.IP
|
||||||
outIPs, err := net.LookupIP(domainOrIP)
|
var err error
|
||||||
|
var isDomain bool
|
||||||
|
if net.ParseIP(domainOrIP) == nil {
|
||||||
|
isDomain = true
|
||||||
|
}
|
||||||
|
if always && isDomain {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if isDomain {
|
||||||
|
outIPs, err = net.LookupIP(domainOrIP)
|
||||||
|
} else {
|
||||||
|
outIPs = []net.IP{net.ParseIP(domainOrIP)}
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -427,7 +427,7 @@ func (req *HTTPRequest) GetAuthDataStr() (basicInfo string, err error) {
|
|||||||
|
|
||||||
authorization = strings.Trim(authorization, " \r\n\t")
|
authorization = strings.Trim(authorization, " \r\n\t")
|
||||||
if authorization == "" {
|
if authorization == "" {
|
||||||
fmt.Fprintf((*req.conn), "HTTP/1.1 %s Unauthorized\r\nWWW-Authenticate: Basic realm=\"\"\r\n\r\nUnauthorized", "407")
|
fmt.Fprintf((*req.conn), "HTTP/1.1 %s Proxy Authentication Required\r\nProxy-Authenticate: Basic realm=\"\"\r\n\r\nProxy Authentication Required", "407")
|
||||||
CloseConn(req.conn)
|
CloseConn(req.conn)
|
||||||
err = errors.New("require auth header data")
|
err = errors.New("require auth header data")
|
||||||
return
|
return
|
||||||
@ -463,7 +463,7 @@ func (req *HTTPRequest) BasicAuth() (err error) {
|
|||||||
authOk := (*req.basicAuth).Check(string(user), addr[0], URL)
|
authOk := (*req.basicAuth).Check(string(user), addr[0], URL)
|
||||||
//log.Printf("auth %s,%v", string(user), authOk)
|
//log.Printf("auth %s,%v", string(user), authOk)
|
||||||
if !authOk {
|
if !authOk {
|
||||||
fmt.Fprintf((*req.conn), "HTTP/1.1 %s Unauthorized\r\n\r\nUnauthorized", "407")
|
fmt.Fprintf((*req.conn), "HTTP/1.1 %s Proxy Authentication Required\r\n\r\nProxy Authentication Required", "407")
|
||||||
CloseConn(req.conn)
|
CloseConn(req.conn)
|
||||||
err = fmt.Errorf("basic auth fail")
|
err = fmt.Errorf("basic auth fail")
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user