mirror of
https://github.com/ehang-io/nps.git
synced 2025-09-03 12:36:54 +00:00
core plugin
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
)
|
||||
|
||||
type Proxy struct {
|
||||
core.NpsPlugin
|
||||
clientConn net.Conn
|
||||
ctx context.Context
|
||||
}
|
||||
@@ -15,20 +16,9 @@ type Proxy struct {
|
||||
func (proxy *Proxy) GetConfigName() *core.NpsConfigs {
|
||||
return core.NewNpsConfigs("socks5_proxy", "proxy to inet")
|
||||
}
|
||||
func (proxy *Proxy) GetStage() core.Stage {
|
||||
return core.STAGE_RUN
|
||||
}
|
||||
|
||||
func (proxy *Proxy) Start(ctx context.Context, config map[string]string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (proxy *Proxy) Run(ctx context.Context, config map[string]string) error {
|
||||
clientCtxConn := ctx.Value(core.CLIENT_CONNECTION)
|
||||
if clientCtxConn == nil {
|
||||
return core.CLIENT_CONNECTION_NOT_EXIST
|
||||
}
|
||||
proxy.clientConn = clientCtxConn.(net.Conn)
|
||||
proxy.clientConn = proxy.GetClientConn(ctx)
|
||||
proxy.ctx = ctx
|
||||
bg := ctx.Value(core.BRIDGE)
|
||||
if bg == nil {
|
||||
@@ -53,7 +43,3 @@ func (proxy *Proxy) Run(ctx context.Context, config map[string]string) error {
|
||||
core.CopyBuffer(clientCtxConn.(net.Conn), severConn)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (proxy *Proxy) End(ctx context.Context, config map[string]string) error {
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user