Giter VIP home page Giter VIP logo

goforward's Introduction

Hi there 👋

goforward's People

Contributors

csznet 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

goforward's Issues

启动报错(数据库)

root@pve:/jk/goForward1# ./go* -pass 666
Data: /jk/goForward1/goForward.db
Web管 理 面 板 端 口 :8889
2024/03/17 21:46:27 /home/runner/work/goForward/goForward/sql/sql.go:101 SQL logic error: no such column
: protocal (1)
[0.143ms] [rows:0] SELECT * FROM `connection_stats` WHERE local_port = "8889" And protocal = "udp"

备注和动态域名支持

大佬,程序很好用。
看能否提供规则备注功能,时间久了,容易忘记添加的是啥。
另外,目标地址能否增加动态域名的支持呢。

出现错误, CPU 占用过高

一使用 ipv6 CPU占用就会很高,只是简单的 ssh,用 ipv4 的时候没发现有问题,一改成 ipv6 连接, CPU 就瞬间升高到 10% ,然后慢慢还能升到接近 100%,断开连接后也不会下降,需要关闭 goforward 才行。
图片
图片
图片
图片
图片
图片

goforward 最新版本 v1.2.2,系统环境如下图
图片

cpu跑满

image

就建立了一条tcp转发,但是cpu跑满

x-ui功能集成

尝试了一下,轻量化很好用,不过直接暴露在公网上还是不太安全,建议先借鉴xui的相关实现

1.自定义路径伪装 ip:port/a1b2c3d4
2.面板访问密码

然后现在用ip:8080/8889都可以访问,第一条规则的存在意义不大,最好有个设置能修改默认端口.然后这个规则目前删除了进程就崩溃,下次开启又会自动创建,可以优化一下

周期性产生异常负载,即使当时没有网络请求

系统是Debian11。

每次服务起来之后可能几个小时或者几天后,goforward就会产生异常负载。
排查了一下这个时候并没有异常的链接,连接数很少(日志显示只有2个)。
然后每次重启一下systemctl restart goForward 就能恢复。不知道是什么原因。

3
2
1

流量单位

// 定时打印和处理流量变化
func (cs *ConnectionStats) printStats(wg *sync.WaitGroup, ctx context.Context) {
	defer wg.Done()
	ticker := time.NewTicker(5 * time.Second)
	defer ticker.Stop() // 在函数结束时停止定时器
	for {
		select {
		case <-ticker.C:
			cs.TotalBytesLock.Lock()
			if cs.TotalBytes > cs.TotalBytesOld {
				if cs.Protocol == "tcp" {
					cs.TcpTime = 0
				}
				var total string
				if cs.TotalBytes > 0 && float64(cs.TotalBytes)/(1024*1024) < 0.5 {
					total = strconv.FormatFloat(float64(cs.TotalBytes)/(1024), 'f', 2, 64) + "KB"
				} else {
					total = strconv.FormatFloat(float64(cs.TotalBytes)/(1024*1024), 'f', 2, 64) + "MB"
				}
				fmt.Printf("【%s】端口 %s 统计流量: %s\n", cs.Protocol, cs.LocalPort, total)
				//统计更换单位
				var gb uint64 = 1073741824
				if cs.TotalBytes >= gb {
					cs.TotalGigabyte = cs.TotalGigabyte + 1
					sql.UpdateForwardGb(cs.Id, cs.TotalGigabyte)
					cs.TotalBytes = cs.TotalBytes - gb
				}
				cs.TotalBytesOld = cs.TotalBytes
				sql.UpdateForwardBytes(cs.Id, cs.TotalBytes)
				fmt.Printf("【%s】端口 %s 当前连接数: %d\n", cs.Protocol, cs.LocalPort, len(cs.TCPConnections))
			} else {
				if cs.Protocol == "tcp" {
					// fmt.Printf("【%s】端口 %s 当前超时秒: %d\n", cs.Protocol, cs.LocalPort, cs.TcpTime)
					if cs.TcpTime >= conf.TcpTimeout {
						// fmt.Printf("【%s】端口 %s 超时关闭\n", cs.Protocol, cs.LocalPort)
						for i := len(cs.TCPConnections) - 1; i >= 0; i-- {
							conn := cs.TCPConnections[i]
							conn.Close()
							// 从连接列表中移除关闭的连接
							cs.TCPConnections = append(cs.TCPConnections[:i], cs.TCPConnections[i+1:]...)
						}
					} else {
						cs.TcpTime = cs.TcpTime + 5
					}
				}
			}
			cs.TotalBytesLock.Unlock()
		//当协程退出时执行
		case <-ctx.Done():
			return
		}
	}
}

以上代码是尚未实现吗

小白问个问题

× goForward.service - Start goForward on boot
Loaded: loaded (/etc/systemd/system/goForward.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Wed 2024-04-17 21:40:06 CST; 36s ago
Duration: 10.111s
Process: 1822 ExecStart=/root/goForward (code=exited, status=2)
Main PID: 1822 (code=exited, status=2)
CPU: 625ms

Apr 17 21:40:06 C20240408212180 goForward[1822]: panic: interface conversion: interface {} is *[]uint8, not []uint8
Apr 17 21:40:06 C20240408212180 goForward[1822]: goroutine 30 [running]:
Apr 17 21:40:06 C20240408212180 goForward[1822]: csz.net/goForward/forward.(*ConnectionStats).copyBytes(0xc00011c120, {0xdc89d0, 0xc0000124b8}, {0xdc89d0, 0xc0000124a0})
Apr 17 21:40:06 C20240408212180 goForward[1822]: /home/runner/work/goForward/goForward/forward/forward.go:208 +0x394
Apr 17 21:40:06 C20240408212180 goForward[1822]: csz.net/goForward/forward.(*ConnectionStats).handleTCPConnection.func2()
Apr 17 21:40:06 C20240408212180 goForward[1822]: /home/runner/work/goForward/goForward/forward/forward.go:154 +0x6c
Apr 17 21:40:06 C20240408212180 goForward[1822]: created by csz.net/goForward/forward.(*ConnectionStats).handleTCPConnection
Apr 17 21:40:06 C20240408212180 goForward[1822]: /home/runner/work/goForward/goForward/forward/forward.go:152 +0x451
Apr 17 21:40:06 C20240408212180 systemd[1]: goForward.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Apr 17 21:40:06 C20240408212180 systemd[1]: goForward.service: Failed with result 'exit-code'.
root@C20240408212180:~#

添加ipv6会崩溃

启动命令为:ExecStart=/usr/local/bin/goForward -pass [密码] -port 30000
在界面添加ipv6,两个相同的端口后,工具崩溃,可复现,日志如下

Apr 17 02:50:44 cn goForward[15293]: goForward Version v1.1.9 Apr 17 02:50:44 cn goForward[15293]: Data: /usr/local/bin/goForward.db Apr 17 02:50:45 cn goForward[15293]: Web<E7><AE><A1><E7><90><86><E9><9D><A2><E6><9D><BF><E7><AB><AF><E5><8F><A3>:30000 Apr 17 02:50:45 cn goForward[15293]: <E3><80><90>udp<E3><80><91><E7>91><E5><90><AC><E7><AB><AF><E5><8F><A3> 30000 <E8><BD><AC><E5><8F><91><E8><87><B3> 127.0.0.1:30000 Apr 17 02:50:51 cn goForward[15293]: [GIN] 2024/04/17 - 02:50:51 | 200 | 802.27<C2><B5>s | 2001:da8:b000:6801:929c:4aff:fec1:f4db | GET "/" Apr 17 02:51:29 cn goForward[15293]: [GIN] 2024/04/17 - 02:51:29 | 200 | 9.659558ms | 2001:da8:b000:6801:929c:4aff:fec1:f4db | POST "/add" Apr 17 02:51:29 cn goForward[15293]: <E3><80><90>udp<E3><80><91><E7>91><E5><90><AC><E7><AB><AF><E5><8F><A3> 35544 <E8><BD><AC><E5><8F><91><E8><87><B3> 2401:1fe0::eef:35544 Apr 17 02:51:29 cn goForward[15293]: 2024/04/17 02:51:29 <E8><A7><A3><E6><9E><90><E8><BF><9C><E7><A8><8B><E5><9C><B0><E5><9D><80><E6><97><B6><E5><8F><91><E7><94><9F><E9><94><99> > Apr 17 02:51:29 cn systemd[1]: goForward.service: Main process exited, code=exited, status=1/FAILURE Apr 17 02:51:29 cn systemd[1]: goForward.service: Failed with result 'exit-code'.

内存的问题

设置端口转发之后,随着时间的流动,内存也越来越大,知道程序奔溃退出

性能问题

作者您好,我想问下UDP的转发,在1000Mb/s的直连环境下转发性能可以做到多少。

增加IP选择

刚刚用上了,太方便了。
不过机器上本地有绑定多个IP,能否在添加时选择要绑定的IP呢,而不是默认的0.0.0.0
感谢。

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.