File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
service/src/main/java/com/github/kr328/clash/service/util Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import java.net.InetAddress
77fun InetAddress.asSocketAddressText (port : Int ): String {
88 return when (this ) {
99 is Inet6Address ->
10- " [${numericToTextFormat(this .address )} ]:$port "
10+ " [${numericToTextFormat(this )} ]:$port "
1111 is Inet4Address ->
1212 " ${this .hostAddress} :$port "
1313 else -> throw IllegalArgumentException (" Unsupported Inet type ${this .javaClass} " )
@@ -16,7 +16,8 @@ fun InetAddress.asSocketAddressText(port: Int): String {
1616
1717private const val INT16SZ = 2
1818private const val INADDRSZ = 16
19- private fun numericToTextFormat (src : ByteArray ): String {
19+ private fun numericToTextFormat (address : Inet6Address ): String {
20+ var src = address.getAddress()
2021 val sb = StringBuilder (39 )
2122 for (i in 0 until INADDRSZ / INT16SZ ) {
2223 sb.append(
@@ -29,6 +30,10 @@ private fun numericToTextFormat(src: ByteArray): String {
2930 sb.append(" :" )
3031 }
3132 }
33+ if (address.getScopeId() > 0 ){
34+ sb.append(" %" )
35+ sb.append(address.getScopeId())
36+ }
3237 return sb.toString()
3338}
3439
You can’t perform that action at this time.
0 commit comments