diff --git a/conf/config.yaml b/conf/config.yaml index 1f53cdef..787115cc 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -13,3 +13,4 @@ proxy: socks5: '' http: '' https: '' + no_proxy: '' diff --git a/internal/core/runner/python/python.go b/internal/core/runner/python/python.go index d309fa4a..91cd8462 100644 --- a/internal/core/runner/python/python.go +++ b/internal/core/runner/python/python.go @@ -13,6 +13,7 @@ import ( "time" "github.com/google/uuid" + "github.com/langgenius/dify-sandbox/internal/core/runner" "github.com/langgenius/dify-sandbox/internal/core/runner/types" "github.com/langgenius/dify-sandbox/internal/static" @@ -68,6 +69,9 @@ func (p *PythonRunner) Run( if configuration.Proxy.Http != "" { cmd.Env = append(cmd.Env, fmt.Sprintf("HTTP_PROXY=%s", configuration.Proxy.Http)) } + if configuration.Proxy.NoProxy != "" { + cmd.Env = append(cmd.Env, fmt.Sprintf("NO_PROXY=%s", configuration.Proxy.NoProxy)) + } } if len(configuration.AllowedSyscalls) > 0 { diff --git a/internal/static/config.go b/internal/static/config.go index 28c443d0..d5640ac8 100644 --- a/internal/static/config.go +++ b/internal/static/config.go @@ -5,9 +5,10 @@ import ( "strconv" "strings" + "gopkg.in/yaml.v3" + "github.com/langgenius/dify-sandbox/internal/types" "github.com/langgenius/dify-sandbox/internal/utils/log" - "gopkg.in/yaml.v3" ) var difySandboxGlobalConfigurations types.DifySandboxGlobalConfigurations @@ -150,6 +151,11 @@ func InitConfig(path string) error { difySandboxGlobalConfigurations.Proxy.Http = http_proxy } + no_proxy := os.Getenv("NO_PROXY") + if no_proxy != "" { + difySandboxGlobalConfigurations.Proxy.NoProxy = no_proxy + } + if difySandboxGlobalConfigurations.Proxy.Http != "" { log.Info("using http proxy: %s", difySandboxGlobalConfigurations.Proxy.Http) } diff --git a/internal/types/config.go b/internal/types/config.go index 34ac33b8..95355689 100644 --- a/internal/types/config.go +++ b/internal/types/config.go @@ -18,8 +18,9 @@ type DifySandboxGlobalConfigurations struct { EnablePreload bool `yaml:"enable_preload"` AllowedSyscalls []int `yaml:"allowed_syscalls"` Proxy struct { - Socks5 string `yaml:"socks5"` - Https string `yaml:"https"` - Http string `yaml:"http"` + Socks5 string `yaml:"socks5"` + Https string `yaml:"https"` + Http string `yaml:"http"` + NoProxy string `yaml:"no_proxy"` } `yaml:"proxy"` -} \ No newline at end of file +}