Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0d99e2f

Browse files
author
Stefania
authored
Merge pull request#201 from hannobraun/proxy-setting
Add configuration setting to set proxy server
2 parentsbd3a6af +2b3cc4d commit0d99e2f

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

‎config.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ regex = usb|acm|com # Regular expression to filter serial port list
44
v = true# show debug logging
55
appName = CreateBridge
66
updateUrl = http://downloads.arduino.cc/
7-
origins = http://local.arduino.cc:8000
7+
origins = http://local.arduino.cc:8080
8+
#httpProxy = http://your.proxy:port # Proxy server for HTTP requests

‎main.go

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ var (
4545

4646
// iniflags
4747
var (
48-
iniConf=flag.NewFlagSet("ini",flag.ContinueOnError)
4948
address=iniConf.String("address","127.0.0.1","The address where to listen. Defaults to localhost")
5049
appName=iniConf.String("appName","","")
5150
gcType=iniConf.String("gc","std","Type of garbage collection. std = Normal garbage collection allowing system to decide (this has been known to cause a stop the world in the middle of a CNC job which can cause lost responses from the CNC controller and thus stalled jobs. use max instead to solve.), off = let memory grow unbounded (you have to send in the gc command manually to garbage collect or you will run out of RAM eventually), max = Force garbage collection on each recv or send on a serial port (this minimizes stop the world events and thus lost serial responses, but increases CPU usage)")
5251
hostname=iniConf.String("hostname","unknown-hostname","Override the hostname we get from the OS")
52+
httpProxy=iniConf.String("httpProxy","","Proxy server for HTTP requests")
53+
httpsProxy=iniConf.String("httpsProxy","","Proxy server for HTTPS requests")
5354
indexURL=iniConf.String("indexURL","https://downloads.arduino.cc/packages/package_staging_index.json","The address from where to download the index json containing the location of upload tools")
55+
iniConf=flag.NewFlagSet("ini",flag.ContinueOnError)
5456
logDump=iniConf.String("log","off","off = (default)")
5557
origins=iniConf.String("origins","","Allowed origin list for CORS")
5658
regExpFilter=iniConf.String("regex","usb|acm|com","Regular expression to filter serial port list")
@@ -178,6 +180,32 @@ func main() {
178180
debug.SetGCPercent(-1)
179181
}
180182

183+
// If the httpProxy setting is set, use its value to override the
184+
// HTTP_PROXY environment variable. Setting this environment
185+
// variable ensures that all HTTP requests using net/http use this
186+
// proxy server.
187+
if*httpProxy!="" {
188+
log.Printf("Setting HTTP_PROXY variable to %v",*httpProxy)
189+
err:=os.Setenv("HTTP_PROXY",*httpProxy)
190+
iferr!=nil {
191+
// The os.Setenv documentation doesn't specify how it can
192+
// fail, so I don't know how to handle this error
193+
// appropriately.
194+
panic(err)
195+
}
196+
}
197+
198+
if*httpsProxy!="" {
199+
log.Printf("Setting HTTPS_PROXY variable to %v",*httpProxy)
200+
err:=os.Setenv("HTTPS_PROXY",*httpProxy)
201+
iferr!=nil {
202+
// The os.Setenv documentation doesn't specify how it can
203+
// fail, so I don't know how to handle this error
204+
// appropriately.
205+
panic(err)
206+
}
207+
}
208+
181209
// see if they provided a regex filter
182210
iflen(*regExpFilter)>0 {
183211
log.Printf("You specified a serial port regular expression filter: %v\n",*regExpFilter)
@@ -474,7 +502,7 @@ func parseIni(filename string) (args []string, err error) {
474502
ifkey=="name" {
475503
continue
476504
}
477-
args=append(args,"-"+key,val)
505+
args=append(args,"-"+key+"="+val)
478506
}
479507
}
480508

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp