Openvpn get settings http route
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type (
|
||||
// VPNDevice is the device name used to tunnel using Openvpn
|
||||
VPNDevice string
|
||||
@@ -14,7 +19,45 @@ type (
|
||||
// TinyProxyLogLevel is the log level for TinyProxy
|
||||
TinyProxyLogLevel string
|
||||
// VPNProvider is the name of the VPN provider to be used
|
||||
VPNProvider string // TODO
|
||||
VPNProvider string
|
||||
// NetworkProtocol contains the network protocol to be used to communicate with the VPN servers
|
||||
NetworkProtocol string
|
||||
)
|
||||
|
||||
func marshalJSONString(s string) (data []byte, err error) {
|
||||
return []byte(fmt.Sprintf("%q", s)), nil
|
||||
}
|
||||
|
||||
func unmarshalJSONString(data []byte) (s string) {
|
||||
s = string(data)
|
||||
s = strings.TrimPrefix(s, "\"")
|
||||
s = strings.TrimSuffix(s, "\"")
|
||||
return s
|
||||
}
|
||||
|
||||
func (v *VPNProvider) MarshalJSON() ([]byte, error) {
|
||||
return marshalJSONString(string(*v))
|
||||
}
|
||||
|
||||
func (v *VPNProvider) UnmarshalJSON(data []byte) error {
|
||||
*v = VPNProvider(unmarshalJSONString(data))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *NetworkProtocol) MarshalJSON() ([]byte, error) {
|
||||
return marshalJSONString(string(*n))
|
||||
}
|
||||
|
||||
func (n *NetworkProtocol) UnmarshalJSON(data []byte) error {
|
||||
*n = NetworkProtocol(unmarshalJSONString(data))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *Filepath) MarshalJSON() ([]byte, error) {
|
||||
return marshalJSONString(string(*f))
|
||||
}
|
||||
|
||||
func (f *Filepath) UnmarshalJSON(data []byte) error {
|
||||
*f = Filepath(unmarshalJSONString(data))
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user