mirror of
				https://github.com/OwO-Network/DeepLX.git
				synced 2025-10-31 14:59:48 +00:00 
			
		
		
		
	fix: remove authkey
This commit is contained in:
		
							parent
							
								
									dce5ccd029
								
							
						
					
					
						commit
						29ac0e1589
					
				| @ -63,14 +63,6 @@ func initConfig() *Config { | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// DeepL Official Authentication key flag
 |  | ||||||
| 	flag.StringVar(&cfg.AuthKey, "authkey", "", "The authentication key for DeepL API") |  | ||||||
| 	if cfg.AuthKey == "" { |  | ||||||
| 		if authKey, ok := os.LookupEnv("AUTHKEY"); ok { |  | ||||||
| 			cfg.AuthKey = authKey |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	// HTTP Proxy flag
 | 	// HTTP Proxy flag
 | ||||||
| 	flag.StringVar(&cfg.Proxy, "proxy", "", "set the proxy URL for HTTP requests") | 	flag.StringVar(&cfg.Proxy, "proxy", "", "set the proxy URL for HTTP requests") | ||||||
| 	if cfg.Proxy == "" { | 	if cfg.Proxy == "" { | ||||||
|  | |||||||
							
								
								
									
										19
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								main.go
									
									
									
									
									
								
							| @ -2,7 +2,7 @@ | |||||||
|  * @Author: Vincent Yang |  * @Author: Vincent Yang | ||||||
|  * @Date: 2023-07-01 21:45:34 |  * @Date: 2023-07-01 21:45:34 | ||||||
|  * @LastEditors: Vincent Young |  * @LastEditors: Vincent Young | ||||||
|  * @LastEditTime: 2024-09-16 12:07:15 |  * @LastEditTime: 2024-09-16 12:12:35 | ||||||
|  * @FilePath: /DeepLX/main.go |  * @FilePath: /DeepLX/main.go | ||||||
|  * @Telegram: https://t.me/missuo
 |  * @Telegram: https://t.me/missuo
 | ||||||
|  * @GitHub: https://github.com/missuo
 |  * @GitHub: https://github.com/missuo
 | ||||||
| @ -97,9 +97,6 @@ func main() { | |||||||
| 	if cfg.Token != "" { | 	if cfg.Token != "" { | ||||||
| 		fmt.Println("Access token is set.") | 		fmt.Println("Access token is set.") | ||||||
| 	} | 	} | ||||||
| 	if cfg.AuthKey != "" { |  | ||||||
| 		fmt.Println("DeepL Official Authentication key is set.") |  | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	// Setting the application to release mode
 | 	// Setting the application to release mode
 | ||||||
| 	gin.SetMode(gin.ReleaseMode) | 	gin.SetMode(gin.ReleaseMode) | ||||||
| @ -124,7 +121,6 @@ func main() { | |||||||
| 		translateText := req.TransText | 		translateText := req.TransText | ||||||
| 		tagHandling := req.TagHandling | 		tagHandling := req.TagHandling | ||||||
| 
 | 
 | ||||||
| 		authKey := cfg.AuthKey |  | ||||||
| 		proxyURL := cfg.Proxy | 		proxyURL := cfg.Proxy | ||||||
| 
 | 
 | ||||||
| 		if tagHandling != "" && tagHandling != "html" && tagHandling != "xml" { | 		if tagHandling != "" && tagHandling != "html" && tagHandling != "xml" { | ||||||
| @ -135,7 +131,7 @@ func main() { | |||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		result, err := translate.TranslateByDeepLX(sourceLang, targetLang, translateText, tagHandling, authKey, proxyURL) | 		result, err := translate.TranslateByDeepLX(sourceLang, targetLang, translateText, tagHandling, proxyURL) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			log.Fatalf("Translation failed: %s", err) | 			log.Fatalf("Translation failed: %s", err) | ||||||
| 		} | 		} | ||||||
| @ -225,17 +221,8 @@ func main() { | |||||||
| 
 | 
 | ||||||
| 	// Free API endpoint, Consistent with the official API format
 | 	// Free API endpoint, Consistent with the official API format
 | ||||||
| 	r.POST("/v2/translate", authMiddleware(cfg), func(c *gin.Context) { | 	r.POST("/v2/translate", authMiddleware(cfg), func(c *gin.Context) { | ||||||
| 		authorizationHeader := c.GetHeader("Authorization") |  | ||||||
| 		var authKey string |  | ||||||
| 		proxyURL := cfg.Proxy | 		proxyURL := cfg.Proxy | ||||||
| 
 | 
 | ||||||
| 		if strings.HasPrefix(authorizationHeader, "DeepL-Auth-Key") { |  | ||||||
| 			parts := strings.Split(authorizationHeader, " ") |  | ||||||
| 			if len(parts) >= 2 && strings.HasSuffix(parts[len(parts)-1], ":fx") { |  | ||||||
| 				authKey = parts[len(parts)-1] |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		var translateText string | 		var translateText string | ||||||
| 		var targetLang string | 		var targetLang string | ||||||
| 
 | 
 | ||||||
| @ -260,7 +247,7 @@ func main() { | |||||||
| 			targetLang = jsonData.TargetLang | 			targetLang = jsonData.TargetLang | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		result, err := translate.TranslateByDeepLX("", targetLang, translateText, "", authKey, proxyURL) | 		result, err := translate.TranslateByDeepLX("", targetLang, translateText, "", proxyURL) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			log.Fatalf("Translation failed: %s", err) | 			log.Fatalf("Translation failed: %s", err) | ||||||
| 		} | 		} | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user