forked from DingMStar/proxypool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zu1k
committed
Aug 12, 2020
1 parent
c87b587
commit 21f55ac
Showing
16 changed files
with
691 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package app | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/zu1k/proxypool/config" | ||
"github.com/zu1k/proxypool/getter" | ||
) | ||
|
||
var Getters = make([]getter.Getter, 0) | ||
|
||
func InitGetters(sources []config.Source) { | ||
for _, source := range sources { | ||
g := getter.NewGetter(source.Type, source.Options) | ||
if g != nil { | ||
Getters = append(Getters, g) | ||
fmt.Println("init getter:", source.Type, source.Options) | ||
} | ||
} | ||
fmt.Println("Getter count:", len(Getters)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
|
||
"github.com/ghodss/yaml" | ||
"github.com/zu1k/proxypool/tool" | ||
) | ||
|
||
type Source struct { | ||
Type string `json:"type" yaml:"type"` | ||
Options tool.Options `json:"options" yaml:"options"` | ||
} | ||
|
||
type Config struct { | ||
Sources []Source `json:"sources" yaml:"sources"` | ||
} | ||
|
||
var SourceConfig = Config{} | ||
|
||
func Parse(path string) (*Config, error) { | ||
fileData, err := readFile(path) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
err = yaml.Unmarshal(fileData, &SourceConfig) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &SourceConfig, nil | ||
} | ||
|
||
func readFile(path string) ([]byte, error) { | ||
if _, err := os.Stat(path); os.IsNotExist(err) { | ||
return nil, err | ||
} | ||
data, err := ioutil.ReadFile(path) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if len(data) == 0 { | ||
return nil, fmt.Errorf("Configuration file %s is empty", path) | ||
} | ||
|
||
return data, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
sources: | ||
- type: subscribe | ||
options: | ||
url: https://raw.githubusercontent.com/ssrsub/ssr/master/v2ray | ||
|
||
- type: webfuzz | ||
options: | ||
url: https://merlinblog.xyz/wiki/freess.html | ||
|
||
- type: tgchannel | ||
options: | ||
channel: ssrList | ||
num: 200 | ||
|
||
- type: web-fanqiangdang | ||
options: | ||
url: https://fanqiangdang.com/forum.php?mod=rss&fid=50&auth=0 | ||
num: 200 | ||
|
||
- type: web-freessrxyz | ||
options: | ||
|
||
- type: web-lucnorg | ||
options: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.