mirror of
https://github.com/jeremyd/ergo.git
synced 2026-07-19 22:18:11 -07:00
add PROXY protocol support
This commit is contained in:
@@ -28,6 +28,7 @@ var (
|
||||
"PING": NewPingCommand,
|
||||
"PONG": NewPongCommand,
|
||||
"PRIVMSG": NewPrivMsgCommand,
|
||||
"PROXY": NewProxyCommand,
|
||||
"QUIT": NewQuitCommand,
|
||||
"TOPIC": NewTopicCommand,
|
||||
"USER": NewUserMsgCommand,
|
||||
@@ -581,3 +582,30 @@ func NewCapCommand(args []string) (editableCommand, error) {
|
||||
args: args,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// HAPROXY support
|
||||
type ProxyCommand struct {
|
||||
BaseCommand
|
||||
net string
|
||||
sourceIP string
|
||||
destIP string
|
||||
sourcePort string
|
||||
destPort string
|
||||
}
|
||||
|
||||
func (msg *ProxyCommand) String() string {
|
||||
return fmt.Sprintf("PROXY(sourceIP=%s, sourcePort=%s)", msg.sourceIP, msg.sourcePort)
|
||||
}
|
||||
|
||||
func NewProxyCommand(args []string) (editableCommand, error) {
|
||||
if len(args) < 5 {
|
||||
return nil, NotEnoughArgsError
|
||||
}
|
||||
return &ProxyCommand{
|
||||
net: args[0],
|
||||
sourceIP: args[1],
|
||||
destIP: args[2],
|
||||
sourcePort: args[3],
|
||||
destPort: args[4],
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user