Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复了mac下无法读取config.ini以及无法写入proxy.txt的问题 #4

Merged
merged 2 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func Readfileproxy(Coroutine int, Time int) {
}
func Writeproxytxt(livesocks []string) (flag bool) {
// 指定模式打开文件 追加 文件不存在则创建
file, err := os.OpenFile("proxy.txt", os.O_TRUNC|os.O_CREATE, os.ModePerm)
file, err := os.OpenFile("proxy.txt", os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666)
// 打开异常检测
if err != nil {
fmt.Printf("open file failed, err: %v\n", err)
Expand Down
86 changes: 59 additions & 27 deletions fofa/fofa.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"github.com/gookit/color"
"io/ioutil"
"log"
"net/http"
"os"
"path/filepath"
"reflect"
"runtime"
"strconv"
"strings"
"time"

"github.com/gookit/color"
)

type Config struct {
Expand Down Expand Up @@ -51,34 +51,66 @@ func GetConfig() Config {
//创建一个结构体变量的反射
cr := reflect.ValueOf(c).Elem()
//打开文件io流
f, err := os.Open(GetCurrentAbPathByExecutable() + "\\config.ini")
if err != nil {
//log.Fatal(err)
color.RGBStyleFromString("237,64,35").Println("[Error] Fofa configuration file error!!!")
os.Exit(1)
}
defer func() {
if err = f.Close(); err != nil {
sysType := runtime.GOOS
if sysType == "windows" {
f, err := os.Open(GetCurrentAbPathByExecutable() + "\\config.ini")
if err != nil {
//log.Fatal(err)
color.RGBStyleFromString("237,64,35").Println("[Error] Fofa configuration file error!!!")
os.Exit(1)
}
defer func() {
if err = f.Close(); err != nil {
log.Fatal(err)
}
}()
//我们要逐行读取文件内容
s := bufio.NewScanner(f)
for s.Scan() {
//以=分割,前面为key,后面为value
var str = s.Text()
var index = strings.Index(str, "=")
var key = str[0:index]
var value = str[index+1:]
//通过反射将字段设置进去
cr.FieldByName(key).Set(reflect.ValueOf(value))
}
err = s.Err()
if err != nil {
log.Fatal(err)
}
}()
//我们要逐行读取文件内容
s := bufio.NewScanner(f)
for s.Scan() {
//以=分割,前面为key,后面为value
var str = s.Text()
var index = strings.Index(str, "=")
var key = str[0:index]
var value = str[index+1:]
//通过反射将字段设置进去
cr.FieldByName(key).Set(reflect.ValueOf(value))
}
err = s.Err()
if err != nil {
log.Fatal(err)
//返回Config结构体变量
return *c
} else {
f, err := os.Open(GetCurrentAbPathByExecutable() + "/config.ini")
if err != nil {
//log.Fatal(err)
color.RGBStyleFromString("237,64,35").Println("[Error] Fofa configuration file error!!!")
os.Exit(1)
}
defer func() {
if err = f.Close(); err != nil {
log.Fatal(err)
}
}()
//我们要逐行读取文件内容
s := bufio.NewScanner(f)
for s.Scan() {
//以=分割,前面为key,后面为value
var str = s.Text()
var index = strings.Index(str, "=")
var key = str[0:index]
var value = str[index+1:]
//通过反射将字段设置进去
cr.FieldByName(key).Set(reflect.ValueOf(value))
}
err = s.Err()
if err != nil {
log.Fatal(err)
}
//返回Config结构体变量
return *c
}
//返回Config结构体变量
return *c
}

func fofa_api(keyword string, email string, key string, page int, size int) string {
Expand Down
4 changes: 3 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ usage:
修改(bug)日志:
>1.增加了自定义并发数量以及代理存活验证时间 \
2.优化了控制台显示 \
3.修复了从fofa获取代理卡在98%的问题,大概是因为超时机制没生效导致卡顿
3.修复了从fofa获取代理卡在98%的问题,大概是因为超时机制没生效导致卡顿 \
4.修复了mac下无法读取config.ini以及无法写入proxy.txt的问题 [[fix issues#2]](https://github.com/ja9er/Gofreeproxy/issues/2)

![](image/proxyissus.png)