소스 검색

refactor: add https support

RockyJin 4 년 전
부모
커밋
29ce4b19a5
3개의 변경된 파일19개의 추가작업 그리고 3개의 파일을 삭제
  1. 1 1
      etc/kuiper.yaml
  2. 9 1
      plugins/manager.go
  3. 9 1
      xstream/server/server/rest.go

+ 1 - 1
etc/kuiper.yaml

@@ -18,7 +18,7 @@ basic:
   # The URL where hosts all of pre-build plugins. By default it's at packages.emqx.io
   # The URL where hosts all of pre-build plugins. By default it's at packages.emqx.io
   # There could be several hosts (host can be separated with comma), if same package could be found in the several hosts,
   # There could be several hosts (host can be separated with comma), if same package could be found in the several hosts,
   # then the package in the 1st host will have the highest priority.
   # then the package in the 1st host will have the highest priority.
-  pluginHosts: https://packages.emqx.io
+  pluginHosts:  https://www.emqx.io/downloads
 
 
 # The default options for all rules. Each rule can override this setting by defining its own option
 # The default options for all rules. Each rule can override this setting by defining its own option
 rule:
 rule:

+ 9 - 1
plugins/manager.go

@@ -2,6 +2,7 @@ package plugins
 
 
 import (
 import (
 	"archive/zip"
 	"archive/zip"
+	"crypto/tls"
 	"errors"
 	"errors"
 	"fmt"
 	"fmt"
 	"github.com/emqx/kuiper/common"
 	"github.com/emqx/kuiper/common"
@@ -543,7 +544,14 @@ func downloadFile(filepath string, uri string) error {
 		src = srcFile
 		src = srcFile
 	case "http", "https":
 	case "http", "https":
 		// Get the data
 		// Get the data
-		resp, err := http.Get(uri)
+		timeout := time.Duration(10 * time.Second)
+		client := &http.Client{
+			Timeout: timeout,
+			Transport: &http.Transport{
+				TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
+			},
+		}
+		resp, err := client.Get(uri)
 		if err != nil {
 		if err != nil {
 			return err
 			return err
 		}
 		}

+ 9 - 1
xstream/server/server/rest.go

@@ -1,6 +1,7 @@
 package server
 package server
 
 
 import (
 import (
+	"crypto/tls"
 	"encoding/json"
 	"encoding/json"
 	"fmt"
 	"fmt"
 	"github.com/emqx/kuiper/common"
 	"github.com/emqx/kuiper/common"
@@ -487,7 +488,14 @@ func fetchPluginList(hosts, ptype, os, arch string) (err error, result map[strin
 		tmp := []string{host, "kuiper-plugins", version, os, ptype}
 		tmp := []string{host, "kuiper-plugins", version, os, ptype}
 		//The url is similar to http://host:port/kuiper-plugins/0.9.1/debian/sinks/
 		//The url is similar to http://host:port/kuiper-plugins/0.9.1/debian/sinks/
 		url := strings.Join(tmp, "/")
 		url := strings.Join(tmp, "/")
-		resp, err := http.Get(url)
+		timeout := time.Duration(10 * time.Second)
+		client := &http.Client{
+			Timeout: timeout,
+			Transport: &http.Transport{
+				TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
+			},
+		}
+		resp, err := client.Get(url)
 		logger.Infof("Trying to fetch plugins from url: %s\n", url)
 		logger.Infof("Trying to fetch plugins from url: %s\n", url)
 
 
 		if err != nil {
 		if err != nil {