Support port in domain

This commit is contained in:
风扇滑翔翼 2025-07-12 09:00:39 +00:00 committed by GitHub
parent bcb11ad45f
commit f2195fa9d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,6 +7,7 @@ import (
"fmt"
"net"
"reflect"
"strconv"
"unsafe"
"github.com/xtls/xray-core/main/commands/base"
@ -38,8 +39,13 @@ func executePing(cmd *base.Command, args []string) {
base.Fatalf("domain not specified")
}
domain := cmdPing.Flag.Arg(0)
fmt.Println("Tls ping: ", domain)
domainWithPort := cmdPing.Flag.Arg(0)
fmt.Println("Tls ping: ", domainWithPort)
TargetPort := 443
domain, port, err := net.SplitHostPort(domainWithPort)
if err == nil {
TargetPort, _ = strconv.Atoi(port)
}
var ip net.IP
if len(*pingIPStr) > 0 {
@ -60,7 +66,7 @@ func executePing(cmd *base.Command, args []string) {
fmt.Println("-------------------")
fmt.Println("Pinging without SNI")
{
tcpConn, err := net.DialTCP("tcp", nil, &net.TCPAddr{IP: ip, Port: 443})
tcpConn, err := net.DialTCP("tcp", nil, &net.TCPAddr{IP: ip, Port: TargetPort})
if err != nil {
base.Fatalf("Failed to dial tcp: %s", err)
}