Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4214ec4239 | ||
|
|
504de47999 | ||
|
|
e185d734d0 | ||
|
|
9b1ef52649 | ||
|
|
5c9fc850d8 | ||
|
|
ff96e52a33 | ||
|
|
78004bcd39 | ||
|
|
b16decf976 | ||
|
|
828636553d | ||
|
|
bfcc27e70f | ||
|
|
7cb7d34d42 |
@ -1,4 +1,9 @@
|
||||
proxy更新日志
|
||||
v4.9
|
||||
1.修复了HTTP Basic代理返回不合适的头部,导致浏览器不会弹框,个别代理插件无法认证的问题.
|
||||
2.内网穿透切换smux到yamux.
|
||||
3.优化了HTTP(S)\SOCKS5代理--always的处理逻辑.
|
||||
|
||||
v4.8
|
||||
1.优化了SPS连接HTTP上级的指令,避免了某些代理不响应的问题.
|
||||
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.5 manual](https://github.com/snail007/goproxy/tree/v4.5)
|
||||
- [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
|
||||
```shell
|
||||
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**
|
||||
```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.5手册](https://github.com/snail007/goproxy/tree/v4.5)
|
||||
- [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
|
||||
```shell
|
||||
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.下载自动安装脚本**
|
||||
```shell
|
||||
|
||||
@ -5,7 +5,7 @@ if [ -e /tmp/proxy ]; then
|
||||
fi
|
||||
mkdir /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
|
||||
tar zxvf proxy-linux-amd64.tar.gz
|
||||
|
||||
2
main.go
2
main.go
@ -9,7 +9,7 @@ import (
|
||||
"github.com/snail007/goproxy/services"
|
||||
)
|
||||
|
||||
const APP_VERSION = "4.8"
|
||||
const APP_VERSION = "4.9"
|
||||
|
||||
func main() {
|
||||
err := initConfig()
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
VER="4.8"
|
||||
VER="4.9"
|
||||
RELEASE="release-${VER}"
|
||||
rm -rf .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.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.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.DisableSocks5 = sps.Flag("disable-socks", "disable socks proxy").Default("false").Bool()
|
||||
spsArgs.DisableSS = sps.Flag("disable-ss", "").Hidden().Default("false").Bool()
|
||||
|
||||
//parse args
|
||||
_args := strings.Fields(strings.Trim(serviceArgsStr, " "))
|
||||
|
||||
@ -229,7 +229,7 @@ func (s *HTTP) callback(inConn net.Conn) {
|
||||
address := req.Host
|
||||
host, _, _ := net.SplitHostPort(address)
|
||||
useProxy := false
|
||||
if !utils.IsIternalIP(host) {
|
||||
if !utils.IsIternalIP(host, *s.cfg.Always) {
|
||||
useProxy = true
|
||||
if *s.cfg.Parent == "" {
|
||||
useProxy = false
|
||||
|
||||
@ -14,7 +14,8 @@ import (
|
||||
|
||||
"github.com/snail007/goproxy/utils"
|
||||
|
||||
"github.com/xtaci/smux"
|
||||
//"github.com/xtaci/smux"
|
||||
smux "github.com/hashicorp/yamux"
|
||||
)
|
||||
|
||||
type MuxBridge struct {
|
||||
@ -250,9 +251,9 @@ func (s *MuxBridge) callback(inConn net.Conn, serverID, key string) {
|
||||
index := keys[i]
|
||||
s.log.Printf("select client : %s-%s", key, 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()
|
||||
session.(*smux.Session).SetDeadline(time.Time{})
|
||||
//session.(*smux.Session).SetDeadline(time.Time{})
|
||||
if err != nil {
|
||||
s.log.Printf("%s client session open stream %s fail, err: %s, retrying...", key, serverID, err)
|
||||
time.Sleep(time.Second * 3)
|
||||
|
||||
@ -11,7 +11,8 @@ import (
|
||||
"github.com/snail007/goproxy/utils"
|
||||
|
||||
"github.com/golang/snappy"
|
||||
"github.com/xtaci/smux"
|
||||
//"github.com/xtaci/smux"
|
||||
smux "github.com/hashicorp/yamux"
|
||||
)
|
||||
|
||||
type MuxClient struct {
|
||||
|
||||
@ -15,7 +15,8 @@ import (
|
||||
"github.com/snail007/goproxy/utils"
|
||||
|
||||
"github.com/golang/snappy"
|
||||
"github.com/xtaci/smux"
|
||||
//"github.com/xtaci/smux"
|
||||
smux "github.com/hashicorp/yamux"
|
||||
)
|
||||
|
||||
type MuxServer struct {
|
||||
|
||||
@ -519,7 +519,7 @@ func (s *Socks) proxyTCP(inConn *net.Conn, methodReq socks.MethodsRequest, reque
|
||||
if *s.cfg.Parent != "" {
|
||||
host, _, _ := net.SplitHostPort(request.Addr())
|
||||
useProxy := false
|
||||
if utils.IsIternalIP(host) {
|
||||
if utils.IsIternalIP(host, *s.cfg.Always) {
|
||||
useProxy = false
|
||||
} else {
|
||||
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())
|
||||
utils.IoBind(*inConn, outConn, func(err interface{}) {
|
||||
s.log.Printf("conn %s - %s released", inAddr, request.Addr())
|
||||
s.userConns.Remove(inAddr)
|
||||
}, s.log)
|
||||
if c, ok := s.userConns.Get(inAddr); ok {
|
||||
(*c.(*net.Conn)).Close()
|
||||
|
||||
@ -5,12 +5,14 @@ import (
|
||||
"fmt"
|
||||
logger "log"
|
||||
"net"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/snail007/goproxy/utils"
|
||||
|
||||
"github.com/xtaci/smux"
|
||||
//"github.com/xtaci/smux"
|
||||
smux "github.com/hashicorp/yamux"
|
||||
)
|
||||
|
||||
type ServerConn struct {
|
||||
@ -89,10 +91,12 @@ func (s *TunnelBridge) callback(inConn net.Conn) {
|
||||
var err error
|
||||
//s.log.Printf("connection from %s ", inConn.RemoteAddr())
|
||||
sess, err := smux.Server(inConn, &smux.Config{
|
||||
KeepAliveInterval: 10 * time.Second,
|
||||
KeepAliveTimeout: time.Duration(*s.cfg.Timeout) * time.Second,
|
||||
MaxFrameSize: 4096,
|
||||
MaxReceiveBuffer: 4194304,
|
||||
AcceptBacklog: 256,
|
||||
EnableKeepAlive: true,
|
||||
KeepAliveInterval: 9 * time.Second,
|
||||
ConnectionWriteTimeout: 3 * time.Second,
|
||||
MaxStreamWindowSize: 512 * 1024,
|
||||
LogOutput: os.Stderr,
|
||||
})
|
||||
if err != nil {
|
||||
s.log.Printf("new mux server conn error,ERR:%s", err)
|
||||
|
||||
@ -6,11 +6,13 @@ import (
|
||||
"io"
|
||||
logger "log"
|
||||
"net"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/snail007/goproxy/utils"
|
||||
|
||||
"github.com/xtaci/smux"
|
||||
//"github.com/xtaci/smux"
|
||||
smux "github.com/hashicorp/yamux"
|
||||
)
|
||||
|
||||
type TunnelClient struct {
|
||||
@ -139,10 +141,12 @@ func (s *TunnelClient) GetConn() (conn net.Conn, err error) {
|
||||
if err == nil {
|
||||
conn = net.Conn(&_conn)
|
||||
c, e := smux.Client(conn, &smux.Config{
|
||||
KeepAliveInterval: 10 * time.Second,
|
||||
KeepAliveTimeout: time.Duration(*s.cfg.Timeout) * time.Second,
|
||||
MaxFrameSize: 4096,
|
||||
MaxReceiveBuffer: 4194304,
|
||||
AcceptBacklog: 256,
|
||||
EnableKeepAlive: true,
|
||||
KeepAliveInterval: 9 * time.Second,
|
||||
ConnectionWriteTimeout: 3 * time.Second,
|
||||
MaxStreamWindowSize: 512 * 1024,
|
||||
LogOutput: os.Stderr,
|
||||
})
|
||||
if e != nil {
|
||||
s.log.Printf("new mux client conn error,ERR:%s", e)
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
logger "log"
|
||||
"net"
|
||||
"os"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -13,7 +14,8 @@ import (
|
||||
|
||||
"github.com/snail007/goproxy/utils"
|
||||
|
||||
"github.com/xtaci/smux"
|
||||
//"github.com/xtaci/smux"
|
||||
smux "github.com/hashicorp/yamux"
|
||||
)
|
||||
|
||||
type TunnelServer struct {
|
||||
@ -288,10 +290,12 @@ func (s *TunnelServer) GetConn() (conn net.Conn, err error) {
|
||||
if err == nil {
|
||||
conn = net.Conn(&_conn)
|
||||
c, e := smux.Client(conn, &smux.Config{
|
||||
KeepAliveInterval: 10 * time.Second,
|
||||
KeepAliveTimeout: time.Duration(*s.cfg.Timeout) * time.Second,
|
||||
MaxFrameSize: 4096,
|
||||
MaxReceiveBuffer: 4194304,
|
||||
AcceptBacklog: 256,
|
||||
EnableKeepAlive: true,
|
||||
KeepAliveInterval: 9 * time.Second,
|
||||
ConnectionWriteTimeout: 3 * time.Second,
|
||||
MaxStreamWindowSize: 512 * 1024,
|
||||
LogOutput: os.Stderr,
|
||||
})
|
||||
if e != nil {
|
||||
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)
|
||||
return
|
||||
}
|
||||
func IsIternalIP(domainOrIP string) bool {
|
||||
func IsIternalIP(domainOrIP string, always bool) bool {
|
||||
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 {
|
||||
return false
|
||||
}
|
||||
|
||||
@ -427,7 +427,7 @@ func (req *HTTPRequest) GetAuthDataStr() (basicInfo string, err error) {
|
||||
|
||||
authorization = strings.Trim(authorization, " \r\n\t")
|
||||
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)
|
||||
err = errors.New("require auth header data")
|
||||
return
|
||||
@ -463,7 +463,7 @@ func (req *HTTPRequest) BasicAuth() (err error) {
|
||||
authOk := (*req.basicAuth).Check(string(user), addr[0], URL)
|
||||
//log.Printf("auth %s,%v", string(user), 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)
|
||||
err = fmt.Errorf("basic auth fail")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user