add PROXY protocol support

This commit is contained in:
Jeremy Latt 2014-02-10 18:40:06 -08:00
parent a8141a0e1c
commit 4379cb8e1c
2 changed files with 39 additions and 1 deletions

View file

@ -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
}