usualheart / frp-python Goto Github PK
View Code? Open in Web Editor NEWfrp-python是基于frp原理实现的轻量级python版frp,frp-python具有非常简洁的设计,在速度方面甚至优于frp。
frp-python是基于frp原理实现的轻量级python版frp,frp-python具有非常简洁的设计,在速度方面甚至优于frp。
参考frp的:
我是自己使用,所以给你提供一个取巧的思路(仅自用)。主要考虑是因为你的c/s配置约定是写在命令行参数上的,因此意味着本来“连接数”就有限。
目前假设1 frpc->1 frps的情况。我简单魔改你的程式为“只保留第一次的连接”。这样第一次连接后,后续任何frpc都会直接close(哪怕第一次的连接出错挂了)。这样,只要运维时第一次连接成功,就可以放心的挂这个服务——哪怕frpc挂了,也不会被第三者假冒frpc、进而导致嗅探风险。
这是我首次写python,随便改改供参考。
self.userConns = []
+ self.serverConns = None
......
def accept_frp_connection(self,sock, mask):
frpc_conn, addr = sock.accept()
+ if self.serverConns is None:
+ self.serverConns = frpc_conn
m frpc_conn.setblocking(False)
m # 注册为可读套接字
m sel.register(frpc_conn, selectors.EVENT_READ, self.handle_controller_data)
+ elif addr[0]=='127.0.0.1':
+ frpc_conn.setblocking(False)
+ # 注册为可读套接字
+ sel.register(frpc_conn, selectors.EVENT_READ, self.handle_controller_data)
+ else:
+ print('发现可疑连接:' + str(addr))
+ frpc_conn.close()
还有一个我不是特别明白的地方,ctrl+c关闭应用后,即便netstat也查不到端口了,但是立即启动依旧会报告错误,非常影响连续测试。
frpc_sock.bind(('0.0.0.0', targetport))
OSError: [Errno 98] Address already in use
可能python的端口需要特殊的“安全关闭”方法?
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.