web_lucn_org.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package getter
  2. import (
  3. "encoding/base64"
  4. "encoding/json"
  5. "io/ioutil"
  6. "net/http"
  7. "sync"
  8. "github.com/zu1k/proxypool/tool"
  9. "github.com/zu1k/proxypool/proxy"
  10. )
  11. const lucnorgSsrLink = "https://lncn.org/api/ssrList"
  12. type WebLucnOrg struct {
  13. }
  14. func (w WebLucnOrg) Get() []proxy.Proxy {
  15. resp, err := http.Post(lucnorgSsrLink, "", nil)
  16. if err != nil {
  17. return nil
  18. }
  19. defer resp.Body.Close()
  20. body, err := ioutil.ReadAll(resp.Body)
  21. if err != nil {
  22. return nil
  23. }
  24. response := struct {
  25. Code string `json:"code"`
  26. Ssrs string `json:"ssrs"`
  27. }{}
  28. err = json.Unmarshal(body, &response)
  29. if err != nil {
  30. return nil
  31. }
  32. dec := decryptAesForLucn(response.Code, response.Ssrs)
  33. if dec == nil {
  34. return nil
  35. }
  36. type node struct {
  37. Url string `json:"url"`
  38. }
  39. ssrs := make([]node, 0)
  40. err = json.Unmarshal(dec, &ssrs)
  41. if err != nil {
  42. return nil
  43. }
  44. result := make([]string, 0)
  45. for _, node := range ssrs {
  46. result = append(result, node.Url)
  47. }
  48. return StringArray2ProxyArray(result)
  49. }
  50. func (w WebLucnOrg) Get2Chan(pc chan proxy.Proxy, wg *sync.WaitGroup) {
  51. wg.Add(1)
  52. nodes := w.Get()
  53. for _, node := range nodes {
  54. pc <- node
  55. }
  56. wg.Done()
  57. }
  58. func decryptAesForLucn(code string, c string) []byte {
  59. if code == "" {
  60. code = "abclnv561cqqfg30"
  61. }
  62. cipher, err := base64.StdEncoding.DecodeString(c)
  63. if err != nil {
  64. return nil
  65. }
  66. result := tool.AesEcbDecryptWithPKCS7Unpadding(cipher, []byte(code))
  67. return result
  68. }