File tree Expand file tree Collapse file tree 2 files changed +4
-13
lines changed Expand file tree Collapse file tree 2 files changed +4
-13
lines changed Original file line number Diff line number Diff line change @@ -78,17 +78,8 @@ public static Settings Default
7878 {
7979 if ( EndpointType != EndpointVsock ) return null ;
8080
81- var endpoint = Endpoint ;
82- if ( Endpoint . StartsWith ( "http://" ) )
83- {
84- endpoint = endpoint . Substring ( "http://" . Length ) ;
85- }
86- else if ( Endpoint . StartsWith ( "https://" ) )
87- {
88- endpoint = endpoint . Substring ( "https://" . Length ) ;
89- }
90-
91- var parts = endpoint . Split ( ':' , 2 ) ;
81+ var uri = new Uri ( Endpoint ) ; // UriFormatException is a subclass of FormatException
82+ var parts = uri . Host . Split ( ':' , 2 ) ;
9283 if ( parts . Length != 2 ) throw new FormatException ( $ "Invalid vsock endpoint: { Endpoint } ") ;
9384 try
9485 {
Original file line number Diff line number Diff line change @@ -40,15 +40,15 @@ public Vsock(VsockAddress address)
4040 _endpoint = new VSockEndPoint ( address . ContextId , address . Port ) ;
4141 }
4242
43- internal async ValueTask < Stream > ConnectAsync ( SocketsHttpConnectionContext context , CancellationToken cancellationToken )
43+ internal async ValueTask < Stream > ConnectAsync ( SocketsHttpConnectionContext context , CancellationToken cancellation )
4444 {
4545 if ( ! OperatingSystem . IsLinux ( ) ) throw new PlatformNotSupportedException ( "Vsock is only supported on Linux." ) ;
4646
4747 var socket = VSock . Create ( SocketType . Stream ) ;
4848 try
4949 {
5050 // Have to use `Task.Run` with `Connect` to avoid some compatibility issues(if use ConnectAsync).
51- await Task . Run ( ( ) => socket . Connect ( _endpoint ) , cancellationToken ) ;
51+ await Task . Run ( ( ) => socket . Connect ( _endpoint ) , cancellation ) ;
5252 return new NetworkStream ( socket , true ) ;
5353 }
5454 catch
You can’t perform that action at this time.
0 commit comments