forked from vaxilu/x-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 增加到期时间限制 - 新增配置面板 https 访问后,http 自动跳转 https(同端口) - 降低获取系统连接数的 cpu 使用率 - 优化界面 - VMess 协议 alterId 默认改为 0 - 修复旧版本 iOS 系统白屏问题 - 修复重启面板后 xray 没有启动的问题
- Loading branch information
Showing
22 changed files
with
473 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.2.0 | ||
0.3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package sys | ||
|
||
import ( | ||
_ "unsafe" | ||
) | ||
|
||
//go:linkname HostProc github.com/shirou/gopsutil/internal/common.HostProc | ||
func HostProc(combineWith ...string) string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// +build darwin | ||
|
||
package sys | ||
|
||
import ( | ||
"github.com/shirou/gopsutil/net" | ||
) | ||
|
||
func GetTCPCount() (int, error) { | ||
stats, err := net.Connections("tcp") | ||
if err != nil { | ||
return 0, err | ||
} | ||
return len(stats), nil | ||
} | ||
|
||
func GetUDPCount() (int, error) { | ||
stats, err := net.Connections("udp") | ||
if err != nil { | ||
return 0, err | ||
} | ||
return len(stats), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// +build linux | ||
|
||
package sys | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"io" | ||
"os" | ||
) | ||
|
||
func getLinesNum(filename string) (int, error) { | ||
file, err := os.Open(filename) | ||
if err != nil { | ||
return 0, err | ||
} | ||
defer file.Close() | ||
|
||
sum := 0 | ||
buf := make([]byte, 8192) | ||
for { | ||
n, err := file.Read(buf) | ||
|
||
var buffPosition int | ||
for { | ||
i := bytes.IndexByte(buf[buffPosition:], '\n') | ||
if i < 0 || n == buffPosition { | ||
break | ||
} | ||
buffPosition += i + 1 | ||
sum++ | ||
} | ||
|
||
if err == io.EOF { | ||
return sum, nil | ||
} else if err != nil { | ||
return sum, err | ||
} | ||
} | ||
} | ||
|
||
func GetTCPCount() (int, error) { | ||
root := HostProc() | ||
|
||
tcp4, err := getLinesNum(fmt.Sprintf("%v/net/tcp", root)) | ||
if err != nil { | ||
return tcp4, err | ||
} | ||
tcp6, err := getLinesNum(fmt.Sprintf("%v/net/tcp6", root)) | ||
if err != nil { | ||
return tcp4 + tcp6, nil | ||
} | ||
|
||
return tcp4 + tcp6, nil | ||
} | ||
|
||
func GetUDPCount() (int, error) { | ||
root := HostProc() | ||
|
||
udp4, err := getLinesNum(fmt.Sprintf("%v/net/udp", root)) | ||
if err != nil { | ||
return udp4, err | ||
} | ||
udp6, err := getLinesNum(fmt.Sprintf("%v/net/udp6", root)) | ||
if err != nil { | ||
return udp4 + udp6, nil | ||
} | ||
|
||
return udp4 + udp6, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.