Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta510 #513

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2471,3 +2471,26 @@ func GetNoRetMsg() bool {
}
return instance.Settings.NoRetMsg
}

func GetForceSsl() bool {
mu.RLock()
defer mu.RUnlock()

if instance == nil {
fmt.Println("Warning: instance is nil when trying to ForceSSL value.")
return false
}
return instance.Settings.ForceSSL
}

func GetHttpPortAfterSsl() string {
mu.RLock()
defer mu.RUnlock()

if instance == nil {
fmt.Println("Warning: instance is nil when trying to get HttpPortAfterSSL.")
return "444" // 或者返回一个默认的 ImageLimit 值
}

return instance.Settings.HttpPortAfterSSL
}
34 changes: 17 additions & 17 deletions idmap/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ func SimplifiedStoreIDv2(id string) (int64, error) {

// 根据portValue确定协议
protocol := "http"
if portValue == "443" {
if portValue == "443" || config.GetForceSsl(){
protocol = "https"
}

Expand Down Expand Up @@ -553,7 +553,7 @@ func StoreIDv2(id string) (int64, error) {

// 根据portValue确定协议
protocol := "http"
if portValue == "443" {
if portValue == "443" ||config.GetForceSsl(){
protocol = "https"
}

Expand Down Expand Up @@ -603,7 +603,7 @@ func StoreCachev2(id string) (int64, error) {

// 根据portValue确定协议
protocol := "http"
if portValue == "443" {
if portValue == "443" ||config.GetForceSsl(){
protocol = "https"
}

Expand Down Expand Up @@ -653,7 +653,7 @@ func StoreIDv2Pro(id string, subid string) (int64, int64, error) {

// 根据portValue确定协议
protocol := "http"
if portValue == "443" {
if portValue == "443" ||config.GetForceSsl(){
protocol = "https"
}

Expand Down Expand Up @@ -746,7 +746,7 @@ func RetrieveRowByIDv2Pro(newRowID string, newSubRowID string) (string, string,

// 根据portValue确定协议
protocol := "http"
if portValue == "443" {
if portValue == "443" ||config.GetForceSsl(){
protocol = "https"
}

Expand Down Expand Up @@ -817,7 +817,7 @@ func RetrieveRowByIDv2(rowid string) (string, error) {
// 根据portValue确定协议
protocol := "http"
portValue := config.GetPortValue()
if portValue == "443" {
if portValue == "443" ||config.GetForceSsl(){
protocol = "https"
}
if config.GetLotusGrpc() && config.GetLotusValue() {
Expand Down Expand Up @@ -866,7 +866,7 @@ func RetrieveRowByCachev2(rowid string) (string, error) {
// 根据portValue确定协议
protocol := "http"
portValue := config.GetPortValue()
if portValue == "443" {
if portValue == "443" ||config.GetForceSsl(){
protocol = "https"
}
if config.GetLotusGrpc() && config.GetLotusValue() {
Expand Down Expand Up @@ -947,7 +947,7 @@ func WriteConfigv2(sectionName, keyName, value string) error {

// 根据portValue确定协议
protocol := "http"
if portValue == "443" {
if portValue == "443" ||config.GetForceSsl(){
protocol = "https"
}

Expand Down Expand Up @@ -1023,7 +1023,7 @@ func DeleteConfigv2(sectionName, keyName string) error {
// 根据portValue确定协议
protocol := "http"
portValue := config.GetPortValue()
if portValue == "443" {
if portValue == "443" ||config.GetForceSsl(){
protocol = "https"
}

Expand Down Expand Up @@ -1072,7 +1072,7 @@ func ReadConfigv2(sectionName, keyName string) (string, error) {
// 根据portValue确定协议
protocol := "http"
portValue := config.GetPortValue()
if portValue == "443" {
if portValue == "443" ||config.GetForceSsl(){
protocol = "https"
}
if config.GetLotusGrpc() && config.GetLotusValue() {
Expand Down Expand Up @@ -1236,7 +1236,7 @@ func UpdateVirtualValuev2(oldRowValue, newRowValue int64) error {
serverDir := config.GetServer_dir()
portValue := config.GetPortValue()
protocol := "http"
if portValue == "443" {
if portValue == "443" ||config.GetForceSsl(){
protocol = "https"
}
url := fmt.Sprintf("%s://%s:%s/getid?type=5&oldRowValue=%d&newRowValue=%d", protocol, serverDir, portValue, oldRowValue, newRowValue)
Expand Down Expand Up @@ -1272,7 +1272,7 @@ func RetrieveRealValuev2(virtualValue int64) (string, string, error) {
serverDir := config.GetServer_dir()
portValue := config.GetPortValue()
protocol := "http"
if portValue == "443" {
if portValue == "443" ||config.GetForceSsl(){
protocol = "https"
}
url := fmt.Sprintf("%s://%s:%s/getid?type=6&virtualValue=%d", protocol, serverDir, portValue, virtualValue)
Expand Down Expand Up @@ -1320,7 +1320,7 @@ func RetrieveVirtualValuev2(realValue string) (string, string, error) {

// 根据portValue确定协议
protocol := "http"
if portValue == "443" {
if portValue == "443" ||config.GetForceSsl(){
protocol = "https"
}

Expand Down Expand Up @@ -1374,7 +1374,7 @@ func RetrieveVirtualValuev2Pro(realValue string, realValueSub string) (string, s

// 根据portValue确定协议
protocol := "http"
if portValue == "443" {
if portValue == "443" ||config.GetForceSsl(){
protocol = "https"
}

Expand Down Expand Up @@ -1499,7 +1499,7 @@ func RetrieveRealValuesv2Pro(virtualValue int64, virtualValueSub int64) (string,

// 根据portValue确定协议
protocol := "http"
if portValue == "443" {
if portValue == "443" ||config.GetForceSsl(){
protocol = "https"
}

Expand Down Expand Up @@ -1593,7 +1593,7 @@ func UpdateVirtualValuev2Pro(oldVirtualValue1, newVirtualValue1, oldVirtualValue
serverDir := config.GetServer_dir()
portValue := config.GetPortValue()
protocol := "http"
if portValue == "443" {
if portValue == "443" ||config.GetForceSsl(){
protocol = "https"
}

Expand Down Expand Up @@ -1695,7 +1695,7 @@ func FindSubKeysByIdPro(id string) ([]string, error) {

// 根据portValue确定协议
protocol := "http"
if portValue == "443" {
if portValue == "443" ||config.GetForceSsl(){
protocol = "https"
}

Expand Down
18 changes: 9 additions & 9 deletions images/upload_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func originalUploadBehavior(base64Image string) (string, error) {
// 原有的UploadBase64ImageToServer函数的实现
protocol := "http"
serverPort := config.GetPortValue()
if serverPort == "443" {
if serverPort == "443" ||config.GetForceSsl(){
protocol = "https"
}

Expand All @@ -194,9 +194,9 @@ func originalUploadBehavior(base64Image string) (string, error) {
}

serverDir := config.GetServer_dir()
if serverPort == "443" {
if serverPort == "443" ||config.GetForceSsl(){
protocol = "http"
serverPort = "444"
serverPort = config.GetHttpPortAfterSsl()
}

if isPublicAddress(serverDir) {
Expand Down Expand Up @@ -227,7 +227,7 @@ func UploadBehaviorV3(base64Image string) (string, int, int, error) {
} else {
protocol := "http"
serverPort := config.GetPortValue()
if serverPort == "443" {
if serverPort == "443" ||config.GetForceSsl(){
protocol = "https"
}

Expand All @@ -241,9 +241,9 @@ func UploadBehaviorV3(base64Image string) (string, int, int, error) {
}
return resp, width, height, nil
} else {
if serverPort == "443" {
if serverPort == "443" ||config.GetForceSsl(){
protocol = "http"
serverPort = "444"
serverPort = config.GetHttpPortAfterSsl()
}
url = fmt.Sprintf("%s://127.0.0.1:%s/uploadpicv3", protocol, serverPort)

Expand All @@ -261,7 +261,7 @@ func originalUploadBehaviorRecord(base64Image string) (string, error) {
// 根据serverPort确定协议
protocol := "http"
serverPort := config.GetPortValue()
if serverPort == "443" {
if serverPort == "443" ||config.GetForceSsl(){
protocol = "https"
}

Expand All @@ -278,9 +278,9 @@ func originalUploadBehaviorRecord(base64Image string) (string, error) {

serverDir := config.GetServer_dir()
// 当端口是443时,使用HTTP和444端口
if serverPort == "443" {
if serverPort == "443" ||config.GetForceSsl(){
protocol = "http"
serverPort = "444"
serverPort = config.GetHttpPortAfterSsl()
}

if isPublicAddress(serverDir) {
Expand Down
6 changes: 1 addition & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,11 +459,7 @@ func main() {
r.POST("/uploadrecord", server.UploadBase64RecordHandler(rateLimiter))
// 使用 CreateHandleValidation,传入 WebhookHandler 实例
server.InitPrivateKey(conf.Settings.ClientSecret)
if len(conf.Settings.WebhookPrefixIp) == 0 {
r.POST("/"+conf.Settings.WebhookPath, server.CreateHandleValidationSafe(webhookHandler))
} else {
r.POST("/"+conf.Settings.WebhookPath, server.CreateHandleValidation(webhookHandler, conf.Settings.WebhookPrefixIp))
}
r.POST("/"+conf.Settings.WebhookPath, server.CreateHandleValidationSafe(webhookHandler))

r.Static("/channel_temp", "./channel_temp")
if config.GetFrpPort() == "0" && !config.GetDisableWebui() {
Expand Down
6 changes: 3 additions & 3 deletions oss/baidu.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func originalUploadBehavior(base64Image string) (string, error) {
// 原有的UploadBase64ImageToServer函数的实现
protocol := "http"
serverPort := config.GetPortValue()
if serverPort == "443" {
if serverPort == "443" ||config.GetForceSsl(){
protocol = "https"
}

Expand All @@ -149,9 +149,9 @@ func originalUploadBehavior(base64Image string) (string, error) {
}

serverDir := config.GetServer_dir()
if serverPort == "443" {
if serverPort == "443" ||config.GetForceSsl(){
protocol = "http"
serverPort = "444"
serverPort = config.GetHttpPortAfterSsl()
}

if isPublicAddress(serverDir) {
Expand Down
4 changes: 2 additions & 2 deletions server/uploadpic.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func UploadBase64ImageHandler(rateLimiter *RateLimiter) gin.HandlerFunc {
}
// 根据serverPort确定协议
protocol := "http"
if serverPort == "443" {
if serverPort == "443"||config.GetForceSsl() {
protocol = "https"
}
stun, err := idmap.ReadConfigv2("stun", "addr")
Expand Down Expand Up @@ -277,7 +277,7 @@ func UploadBase64RecordHandler(rateLimiter *RateLimiter) gin.HandlerFunc {

// 根据serverPort确定协议
protocol := "http"
if serverPort == "443" {
if serverPort == "443" ||config.GetForceSsl(){
protocol = "https"
}

Expand Down
Loading
Loading