remotetrustcompileconfig.go 638 B

123456789101112131415161718192021222324
  1. package remotetrustcompile
  2. import "github.com/SongZihuan/huan-proxy/src/config/rules/action/remotetrust"
  3. type RemoteTrustCompileConfig struct {
  4. UseTrustedIPs bool
  5. TrustedIPs []string
  6. }
  7. func NewRemoteTrustCompileConfig(r *remotetrust.RemoteTrustConfig) (*RemoteTrustCompileConfig, error) {
  8. if r.RemoteTrust.IsDisable(false) {
  9. return &RemoteTrustCompileConfig{
  10. UseTrustedIPs: false,
  11. TrustedIPs: make([]string, 0),
  12. }, nil
  13. } else {
  14. trustedIPs := make([]string, len(r.TrustedIPs))
  15. copy(trustedIPs, r.TrustedIPs)
  16. return &RemoteTrustCompileConfig{
  17. UseTrustedIPs: true,
  18. TrustedIPs: trustedIPs,
  19. }, nil
  20. }
  21. }