Skip to content

Commit

Permalink
feat:增加参数loglevel,指定日志等级
Browse files Browse the repository at this point in the history
  • Loading branch information
0990 committed Mar 19, 2023
1 parent 939cb9b commit 513f6f8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tproxy2socks
将iptables(TPROXY)透明代理流量转换为socks5流量的golang版工具,类似工具有[zfl9/ipt2socks](https://github.com/zfl9/ipt2socks)
将iptables(TPROXY)透明代理流量转换为socks5流量的golang版工具,类似工具有[ipt2socks](https://github.com/zfl9/ipt2socks),[redsocks](https://github.com/darkk/redsocks)

## 特性
* 支持转成sock4,socks4a流量
Expand All @@ -12,10 +12,10 @@ tproxy2socks --listen=0.0.0.0:60080 --proxy=socks5://127.0.0.1:1080

### 参数
```
--listen 本地监听地址,格式为x.x.x.x:xx
--proxy sock5代理地址,格式为sock5://x.x.x.x:xx或sock4://x.x.x.x:xx
--udptimeout udp超时时间(单位秒)
--verbose 若指定此选项,则将会打印较为详尽的运行时日志
--listen 本地监听地址,格式为x.x.x.x:xx,默认为0.0.0.0:60080
--proxy sock5代理地址,格式为sock5://x.x.x.x:xx或sock4://x.x.x.x:xx,默认为socks5://127.0.0.1:1080
--udptimeout udp超时时间(单位秒),默认为60s
--loglevel 日志打印等级,有debug,info,warn,error,默认为error
```


Expand Down
11 changes: 6 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ import (
var proxy = flag.String("proxy", "socks5://127.0.0.1:1080", "Use this proxy [protocol://]host[:port]")
var listen = flag.String("listen", "0.0.0.0:60080", "listen addr")
var udpTimeout = flag.Int("udptimeout", 60, "udp timeout second")
var verbose = flag.Bool("verbose", false, "print verbose log, affect performance")
var logLevel = flag.String("loglevel", "error", "log level,debug,info,warn,error")

func main() {
flag.Parse()

if *verbose {
logrus.SetLevel(logrus.DebugLevel)
} else {
logrus.SetLevel(logrus.WarnLevel)
level, err := logrus.ParseLevel(*logLevel)
if err != nil {
logrus.Fatalln(fmt.Errorf("loglevel not valid:%w", level))
}

logrus.SetLevel(level)

server, err := tproxy2socks.NewServer(tproxy2socks.Config{
Proxy: *proxy,
ListenAddr: *listen,
Expand Down

0 comments on commit 513f6f8

Please sign in to comment.