diff --git a/option.go b/option.go new file mode 100644 index 0000000..e86ae55 --- /dev/null +++ b/option.go @@ -0,0 +1,22 @@ +package udpproxy + +import ( + "time" + + log "github.com/sirupsen/logrus" +) + +// Option is a functional option type that allows us to configure the Client. +type Option func(*Client) + +// WithSessionTimeout is a functional option to set the session timeout +func WithSessionTimeout(timeout time.Duration) Option { + return func(c *Client) { + if timeout < time.Minute { + log.Warnf("cannot set stale session timeout to less than 1 minute.. defaulting to 20 minutes") + return + } + + c.sessionTimeout = timeout + } +} diff --git a/udpproxy.go b/udpproxy.go index 5198d10..df43756 100644 --- a/udpproxy.go +++ b/udpproxy.go @@ -7,21 +7,6 @@ import ( log "github.com/sirupsen/logrus" ) -// Option is a functional option type that allows us to configure the Client. -type Option func(*Client) - -// WithSessionTimeout is a functional option to set the session timeout -func WithSessionTimeout(timeout time.Duration) Option { - return func(c *Client) { - if timeout < time.Minute { - log.Warnf("cannot set stale session timeout to less than 1 minute.. defaulting to 20 minutes") - return - } - - c.sessionTimeout = timeout - } -} - type Client struct { laddr *net.UDPAddr raddr *net.UDPAddr