Fix Tails/OnionGrater Quoted Response Issue
This commit is contained in:
parent
5996d426c1
commit
a68c0fd160
|
@ -1,9 +1,8 @@
|
||||||
package control
|
package control
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
"git.openprivacy.ca/openprivacy/bine/torutil"
|
"git.openprivacy.ca/openprivacy/bine/torutil"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Signal invokes SIGNAL.
|
// Signal invokes SIGNAL.
|
||||||
|
|
1
go.mod
1
go.mod
|
@ -3,6 +3,7 @@ module git.openprivacy.ca/openprivacy/bine
|
||||||
go 1.14
|
go 1.14
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
git.openprivacy.ca/openprivacy/log v1.0.3
|
||||||
github.com/stretchr/testify v1.6.1
|
github.com/stretchr/testify v1.6.1
|
||||||
golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee
|
golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee
|
||||||
golang.org/x/net v0.0.0-20201010224723-4f7140c49acb
|
golang.org/x/net v0.0.0-20201010224723-4f7140c49acb
|
||||||
|
|
|
@ -78,12 +78,23 @@ func (t *Tor) Dialer(ctx context.Context, conf *DialConf) (*Dialer, error) {
|
||||||
if len(info) != 1 || info[0].Key != "net/listeners/socks" {
|
if len(info) != 1 || info[0].Key != "net/listeners/socks" {
|
||||||
return nil, fmt.Errorf("Unable to get socks proxy address")
|
return nil, fmt.Errorf("Unable to get socks proxy address")
|
||||||
}
|
}
|
||||||
proxyAddress = info[0].Val
|
|
||||||
if strings.HasPrefix(proxyAddress, "unix:") {
|
if strings.HasPrefix(info[0].Val, "\"") {
|
||||||
proxyAddress = proxyAddress[5:]
|
options := strings.Split(info[0].Val, " ")
|
||||||
proxyNetwork = "unix"
|
// we get this kind of response from Tails / OnionGrater, multiple potential listeners
|
||||||
} else {
|
// formatted. Simply choose the first one.
|
||||||
|
// NOTE: This logic is probably not the best...
|
||||||
|
proxyAddress = options[0][1 : len(options[0])-1]
|
||||||
proxyNetwork = "tcp"
|
proxyNetwork = "tcp"
|
||||||
|
} else {
|
||||||
|
|
||||||
|
proxyAddress = info[0].Val
|
||||||
|
if strings.HasPrefix(proxyAddress, "unix:") {
|
||||||
|
proxyAddress = proxyAddress[5:]
|
||||||
|
proxyNetwork = "unix"
|
||||||
|
} else {
|
||||||
|
proxyNetwork = "tcp"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if proxyNetwork == "" {
|
} else if proxyNetwork == "" {
|
||||||
proxyNetwork = "tcp"
|
proxyNetwork = "tcp"
|
||||||
|
|
|
@ -70,7 +70,11 @@ func UnescapeSimpleQuotedString(str string) (string, error) {
|
||||||
if len(str) < 2 || str[0] != '"' || str[len(str)-1] != '"' {
|
if len(str) < 2 || str[0] != '"' || str[len(str)-1] != '"' {
|
||||||
return "", fmt.Errorf("Missing quotes")
|
return "", fmt.Errorf("Missing quotes")
|
||||||
}
|
}
|
||||||
return UnescapeSimpleQuotedStringContents(str[1 : len(str)-1])
|
if str, err := UnescapeSimpleQuotedStringContents(str[1 : len(str)-1]); err == nil {
|
||||||
|
return str, nil
|
||||||
|
}
|
||||||
|
// Assume this wasn't quoted
|
||||||
|
return str, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnescapeSimpleQuotedStringContents unescapes backslashes, double quotes,
|
// UnescapeSimpleQuotedStringContents unescapes backslashes, double quotes,
|
||||||
|
|
Loading…
Reference in New Issue