Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions conf/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ proxy:
socks5: ''
http: ''
https: ''
no_proxy: ''
4 changes: 4 additions & 0 deletions internal/core/runner/python/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 7 additions & 1 deletion internal/static/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
9 changes: 5 additions & 4 deletions internal/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
}