From 4bf887e75f6929f11783a8c995fbbce737cfcc73 Mon Sep 17 00:00:00 2001 From: ston1th Date: Wed, 20 Oct 2021 20:25:02 +0200 Subject: [PATCH] added proxyprotocol parser --- pkg/api/v1/schema/schema.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/api/v1/schema/schema.go b/pkg/api/v1/schema/schema.go index 28923dc..05ba1a5 100644 --- a/pkg/api/v1/schema/schema.go +++ b/pkg/api/v1/schema/schema.go @@ -25,6 +25,18 @@ const ( ProxyProtocolV2 = "v2" ) +func ParseProxyProtocol(s string) (pp ProxyProtocol, err error) { + switch s { + case "v1": + pp = ProxyProtocolV1 + case "v2": + pp = ProxyProtocolV2 + default: + err = errors.New("invalid proxyprotocol version") + } + return +} + type LoadBalancer struct { Name string `json:"name,omitempty"` IP string `json:"ip,omitempty"`