@@ -57,18 +57,32 @@ final class Server
57
57
* @param ?ConnectorInterface $connector
58
58
* @param null|array|callable $auth
59
59
*/
60
- public function __construct (LoopInterface $ loop = null , ConnectorInterface $ connector = null , $ auth = null )
61
- {
60
+ public function __construct (
61
+ LoopInterface $ loop = null ,
62
+ ConnectorInterface $ connector = null ,
63
+ #[\SensitiveParameter]
64
+ $ auth = null
65
+ ) {
62
66
if (\is_array ($ auth )) {
63
67
// wrap authentication array in authentication callback
64
- $ this ->auth = function ($ username , $ password ) use ($ auth ) {
68
+ $ this ->auth = function (
69
+ $ username ,
70
+ #[\SensitiveParameter]
71
+ $ password
72
+ ) use ($ auth ) {
65
73
return \React \Promise \resolve (
66
74
isset ($ auth [$ username ]) && (string )$ auth [$ username ] === $ password
67
75
);
68
76
};
69
77
} elseif (\is_callable ($ auth )) {
70
78
// wrap authentication callback in order to cast its return value to a promise
71
- $ this ->auth = function ($ username , $ password , $ remote ) use ($ auth ) {
79
+ $ this ->auth = function (
80
+ $ username ,
81
+ #[\SensitiveParameter]
82
+ $ password ,
83
+ #[\SensitiveParameter]
84
+ $ remote
85
+ ) use ($ auth ) {
72
86
return \React \Promise \resolve (
73
87
\call_user_func ($ auth , $ username , $ password , $ remote )
74
88
);
@@ -247,7 +261,10 @@ public function handleSocks5(ConnectionInterface $stream, $auth, StreamReader $r
247
261
})->then (function ($ username ) use ($ reader , $ auth , $ stream , &$ remote ) {
248
262
return $ reader ->readByte ()->then (function ($ length ) use ($ reader ) {
249
263
return $ reader ->readLength ($ length );
250
- })->then (function ($ password ) use ($ username , $ auth , $ stream , &$ remote ) {
264
+ })->then (function (
265
+ #[\SensitiveParameter]
266
+ $ password
267
+ ) use ($ username , $ auth , $ stream , &$ remote ) {
251
268
// username and password given => authenticate
252
269
253
270
// prefix username/password to remote URI
0 commit comments