Skip to content

Commit

Permalink
Client config file
Browse files Browse the repository at this point in the history
  • Loading branch information
刘河 committed Mar 24, 2019
1 parent e4b08b1 commit e9256ab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
25 changes: 15 additions & 10 deletions lib/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func dealCommon(s string) *CommonConfig {
c := &CommonConfig{}
c.Cnf = new(file.Config)
c.Client = file.NewClient("", true, true)
for _, v := range strings.Split(s, "\n") {
for _, v := range splitStr(s) {
item := strings.Split(v, "=")
if len(item) == 0 {
continue
Expand Down Expand Up @@ -146,12 +146,7 @@ func dealCommon(s string) *CommonConfig {
func dealHost(s string) *file.Host {
h := &file.Host{}
var headerChange string
var configDataArr []string
configDataArr = strings.Split(s, "\n")
if len(configDataArr) < 3 {
configDataArr = strings.Split(s, "\r\n")
}
for _, v := range configDataArr {
for _, v := range splitStr(s) {
item := strings.Split(v, "=")
if len(item) == 0 {
continue
Expand Down Expand Up @@ -181,7 +176,7 @@ func dealHost(s string) *file.Host {

func dealHealth(s string) *file.Health {
h := &file.Health{}
for _, v := range strings.Split(s, "\n") {
for _, v := range splitStr(s) {
item := strings.Split(v, "=")
if len(item) == 0 {
continue
Expand All @@ -208,7 +203,7 @@ func dealHealth(s string) *file.Health {

func dealTunnel(s string) *file.Tunnel {
t := &file.Tunnel{}
for _, v := range strings.Split(s, "\n") {
for _, v := range splitStr(s) {
item := strings.Split(v, "=")
if len(item) == 0 {
continue
Expand Down Expand Up @@ -238,7 +233,7 @@ func dealTunnel(s string) *file.Tunnel {

func delLocalService(s string) *LocalServer {
l := new(LocalServer)
for _, v := range strings.Split(s, "\n") {
for _, v := range splitStr(s) {
item := strings.Split(v, "=")
if len(item) == 0 {
continue
Expand Down Expand Up @@ -274,3 +269,13 @@ func getAllTitle(content string) (arr []string, err error) {
}
return
}

func splitStr(s string) (configDataArr []string) {
if common.IsWindows() {
configDataArr = strings.Split(s, "\r\n")
}
if len(configDataArr) < 3 {
configDataArr = strings.Split(s, "\n")
}
return
}
2 changes: 1 addition & 1 deletion lib/version/version.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package version

const VERSION = "0.19.0"
const VERSION = "0.19.1"

// Compulsory minimum version, Minimum downward compatibility to this version
func GetVersion() string {
Expand Down

0 comments on commit e9256ab

Please sign in to comment.