Skip to content

Commit

Permalink
🐛 fix: Client rejection on auth
Browse files Browse the repository at this point in the history
  • Loading branch information
MoIzadloo committed Mar 14, 2023
1 parent 8be7f10 commit b366cfb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const server = createServer({

// For development purposes
server.on('data', (data) => {
// Log incoming requests
// Log incoming data
console.log(data)
})

Expand Down Expand Up @@ -210,7 +210,7 @@ you can easily implement it in a matter of seconds.
)
)

socket.once('data', (data) => {
socket.on('data', (data) => {
console.log(data)
})
```
Expand All @@ -237,7 +237,7 @@ you can easily implement it in a matter of seconds.
)
)

socket1.once('data', (data) => {
socket1.on('data', (data) => {
console.log(data)
})

Expand All @@ -252,7 +252,7 @@ you can easily implement it in a matter of seconds.
)
)

socket2.once('data', (data) => {
socket2.on('data', (data) => {
console.log(data)
})
```
Expand Down Expand Up @@ -293,7 +293,7 @@ as an argument (userId) to the request handler (connect | bind | associate).
)
)

socket.once('data', (data) => {
socket.on('data', (data) => {
console.log(data)
})
```
Expand Down Expand Up @@ -322,7 +322,7 @@ as an argument (userId) to the request handler (connect | bind | associate).
)
)

socket.once('data', (data) => {
socket.on('data', (data) => {
console.log(data)
})
```
Expand Down
3 changes: 3 additions & 0 deletions src/client/auth/methods/userPass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class UserPassReqState extends State {
*/
reply(): void {
if (this.status !== 0x00) {
if (this.context.reject) {
this.context.reject('Wrong credentials supplied')
}
this.context.close()
} else {
this.context.transitionTo(new RequestState(this.context))
Expand Down
18 changes: 11 additions & 7 deletions src/client/state/socks5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ export class MethodSelectionState extends State {
* @returns void
*/
reply(): void {
this.context.handlers.auth
.find((method) => {
if (this.method && method) {
return method.method === this.method.readInt8()
}
})
?.authenticate(this.context)
if (this.method?.readInt8() === -1 && this.context.reject) {
this.context.reject('Authentication methods are not acceptable')
} else {
this.context.handlers.auth
.find((method) => {
if (this.method && method) {
return method.method === this.method.readInt8()
}
})
?.authenticate(this.context)
}
}
}

Expand Down

0 comments on commit b366cfb

Please sign in to comment.