Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Anti-censorship
Pluggable Transports
Snowflake
Commits
6e8fbe54
Verified
Commit
6e8fbe54
authored
Apr 29, 2022
by
shelikhoo
Browse files
Rejection reason feedback
parent
3ebb5a41
Changes
2
Hide whitespace changes
Inline
Side-by-side
broker/ipc.go
View file @
6e8fbe54
...
...
@@ -72,7 +72,13 @@ func (i *IPC) ProxyPolls(arg messages.Arg, response *[]byte) error {
}
if
!
i
.
ctx
.
CheckProxyRelayPattern
(
relayPattern
,
!
relayPatternSupported
)
{
return
fmt
.
Errorf
(
"bad request: rejected relay pattern from proxy = %v"
,
messages
.
ErrBadRequest
)
log
.
Printf
(
"bad request: rejected relay pattern from proxy = %v"
,
messages
.
ErrBadRequest
)
b
,
err
:=
messages
.
EncodePollResponseWithRelayURL
(
""
,
false
,
""
,
""
,
"incorrect relay pattern"
)
*
response
=
b
if
err
!=
nil
{
return
messages
.
ErrInternal
}
return
nil
}
// Log geoip stats
...
...
@@ -112,7 +118,7 @@ func (i *IPC) ProxyPolls(arg messages.Arg, response *[]byte) error {
}
else
{
relayURL
=
info
.
WebSocketAddress
}
b
,
err
=
messages
.
EncodePollResponseWithRelayURL
(
string
(
offer
.
sdp
),
true
,
offer
.
natType
,
relayURL
)
b
,
err
=
messages
.
EncodePollResponseWithRelayURL
(
string
(
offer
.
sdp
),
true
,
offer
.
natType
,
relayURL
,
""
)
if
err
!=
nil
{
return
messages
.
ErrInternal
}
...
...
common/messages/proxy.go
View file @
6e8fbe54
...
...
@@ -181,10 +181,10 @@ type ProxyPollResponse struct {
}
func
EncodePollResponse
(
offer
string
,
success
bool
,
natType
string
)
([]
byte
,
error
)
{
return
EncodePollResponseWithRelayURL
(
offer
,
success
,
natType
,
""
)
return
EncodePollResponseWithRelayURL
(
offer
,
success
,
natType
,
""
,
"no match"
)
}
func
EncodePollResponseWithRelayURL
(
offer
string
,
success
bool
,
natType
,
relayURL
string
)
([]
byte
,
error
)
{
func
EncodePollResponseWithRelayURL
(
offer
string
,
success
bool
,
natType
,
relayURL
,
failReason
string
)
([]
byte
,
error
)
{
if
success
{
return
json
.
Marshal
(
ProxyPollResponse
{
Status
:
"client match"
,
...
...
@@ -195,7 +195,7 @@ func EncodePollResponseWithRelayURL(offer string, success bool, natType, relayUR
}
return
json
.
Marshal
(
ProxyPollResponse
{
Status
:
"no match"
,
Status
:
failReason
,
})
}
func
DecodePollResponse
(
data
[]
byte
)
(
string
,
string
,
error
)
{
...
...
@@ -219,12 +219,16 @@ func DecodePollResponseWithRelayURL(data []byte) (string, string, string, error)
return
""
,
""
,
""
,
fmt
.
Errorf
(
"received invalid data"
)
}
err
=
nil
if
message
.
Status
==
"client match"
{
if
message
.
Offer
==
""
{
return
""
,
""
,
""
,
fmt
.
Errorf
(
"no supplied offer"
)
}
}
else
{
message
.
Offer
=
""
if
message
.
Status
!=
"no match"
{
err
=
errors
.
New
(
message
.
Status
)
}
}
natType
:=
message
.
NAT
...
...
@@ -232,7 +236,7 @@ func DecodePollResponseWithRelayURL(data []byte) (string, string, string, error)
natType
=
"unknown"
}
return
message
.
Offer
,
natType
,
message
.
RelayURL
,
nil
return
message
.
Offer
,
natType
,
message
.
RelayURL
,
err
}
type
ProxyAnswerRequest
struct
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment