Skip to content

Commit

Permalink
Merge 26dfe5c into 9e784c2
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoshinonyaruko authored Nov 24, 2024
2 parents 9e784c2 + 26dfe5c commit c54022c
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 33 deletions.
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: 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
4 changes: 2 additions & 2 deletions url/shorturl.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func GenerateShortURL(longURL string) string {
// 根据portValue确定协议
protocol := "http"
portValue := config.GetPortValue()
if portValue == "443" {
if portValue == "443" ||config.GetForceSsl(){
protocol = "https"
}

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

Expand Down

0 comments on commit c54022c

Please sign in to comment.