mirror of
https://github.com/onyx-and-iris/q3rcon-proxy.git
synced 2025-06-07 19:50:23 +01:00
move the functional option into option.go
This commit is contained in:
parent
80ef18f705
commit
a00796254d
22
option.go
Normal file
22
option.go
Normal file
@ -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
|
||||||
|
}
|
||||||
|
}
|
15
udpproxy.go
15
udpproxy.go
@ -7,21 +7,6 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
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 {
|
type Client struct {
|
||||||
laddr *net.UDPAddr
|
laddr *net.UDPAddr
|
||||||
raddr *net.UDPAddr
|
raddr *net.UDPAddr
|
||||||
|
Loading…
x
Reference in New Issue
Block a user