Skip to content

Commit

Permalink
Fixes #29 (#30)
Browse files Browse the repository at this point in the history
Added support of `session_timeout` param
  • Loading branch information
disc authored Feb 17, 2023
1 parent 519210b commit 194e046
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions internal/pritunl/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ func (c client) CreateServer(serverData map[string]interface{}) (*Server, error)
serverStruct.LinkPingTimeout = v.(int)
}

if v, ok := serverData["session_timeout"]; ok {
serverStruct.SessionTimeout = v.(int)
}

if v, ok := serverData["inactive_timeout"]; ok {
serverStruct.InactiveTimeout = v.(int)
}
Expand Down
15 changes: 14 additions & 1 deletion internal/provider/resource_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,18 @@ func resourceServer() *schema.Resource {
Description: "Optional, ping timeout used when multiple users have the same network link to failover to another user when one network link fails..",
ValidateFunc: validation.IntAtLeast(0),
},
"session_timeout": {
Type: schema.TypeInt,
Required: false,
Optional: true,
Description: "Disconnect users after the specified number of seconds.",
ValidateFunc: validation.IntAtLeast(1),
},
"inactive_timeout": {
Type: schema.TypeInt,
Required: false,
Optional: true,
Description: "Disconnects users after the specified number of seconds of inactivity..",
Description: "Disconnects users after the specified number of seconds of inactivity.",
ValidateFunc: validation.IntAtLeast(1),
},
"max_clients": {
Expand Down Expand Up @@ -495,6 +502,7 @@ func resourceReadServer(ctx context.Context, d *schema.ResourceData, meta interf
d.Set("ping_timeout", server.PingTimeout)
d.Set("link_ping_interval", server.LinkPingInterval)
d.Set("link_ping_timeout", server.LinkPingTimeout)
d.Set("session_timeout", server.SessionTimeout)
d.Set("inactive_timeout", server.InactiveTimeout)
d.Set("max_clients", server.MaxClients)
d.Set("network_mode", server.NetworkMode)
Expand Down Expand Up @@ -614,6 +622,7 @@ func resourceCreateServer(ctx context.Context, d *schema.ResourceData, meta inte
"ping_timeout": d.Get("ping_timeout"),
"link_ping_interval": d.Get("link_ping_interval"),
"link_ping_timeout": d.Get("link_ping_timeout"),
"session_timeout": d.Get("session_timeout"),
"inactive_timeout": d.Get("inactive_timeout"),
"max_clients": d.Get("max_clients"),
"network_mode": d.Get("network_mode"),
Expand Down Expand Up @@ -785,6 +794,10 @@ func resourceUpdateServer(ctx context.Context, d *schema.ResourceData, meta inte
server.LinkPingTimeout = d.Get("link_ping_timeout").(int)
}

if d.HasChange("session_timeout") {
server.SessionTimeout = d.Get("session_timeout").(int)
}

if d.HasChange("inactive_timeout") {
server.InactiveTimeout = d.Get("inactive_timeout").(int)
}
Expand Down

0 comments on commit 194e046

Please sign in to comment.