[mike@mwxm4]
This commit is contained in:
@@ -29,16 +29,14 @@ import (
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
var tbversion = "0.4.3"
|
||||
var tbversion = "0.5.0"
|
||||
|
||||
var CHRS = "VW9IdGJ6eXh1T25DRHdrc2M5MlhOQVNQcEJFWnJhWVY2ZEowaFJLdmoxNUdxVDRJZkZpTTdRZW0zTFc4Z2w="
|
||||
var LR = []rune("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||
|
||||
|
||||
|
||||
func checkforupdate() { // --------------------------------------------------------------- check for new version
|
||||
func checkforupdate(URL string) { // ----------------------------------------------------- check for new version
|
||||
prg := prgname()
|
||||
resp, err := http.Get(VERSIONURL)
|
||||
resp, err := http.Get(URL+"/version.txt")
|
||||
if err == nil {
|
||||
scanner := bufio.NewScanner(resp.Body)
|
||||
if scanner.Scan() {
|
||||
@@ -51,7 +49,7 @@ func checkforupdate() { // -----------------------------------------------------
|
||||
ans:=Yesno(SF("new '%s' version found (%s -> %s), update now?",
|
||||
prg,sv_version,sv_lversion),true,false);
|
||||
if (ans) {
|
||||
updateurl:=SF("%s/%s_%s_%s_%s",UPDATEBASEURL,prg,lversion,runtime.GOOS,runtime.GOARCH)
|
||||
updateurl:=SF("%s/%s_%s_%s_%s",URL,prg,lversion,runtime.GOOS,runtime.GOARCH)
|
||||
|
||||
if err := doupdate(updateurl); err != nil {
|
||||
PO(SF("Update failed: %v\n", err))
|
||||
@@ -79,6 +77,25 @@ func doupdate(url string) error { // -------------------------------------------
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkaccess(NETS []string) { // ------------------------------------------------- check ip net based access
|
||||
match:=0;
|
||||
for _, validnet := range NETS {
|
||||
addrs, err := net.InterfaceAddrs()
|
||||
if err != nil { PE("Error getting addresses"); os.Exit(1) }
|
||||
_, ipNet, err := net.ParseCIDR(validnet)
|
||||
for _, address := range addrs {
|
||||
if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
|
||||
if ipnet.IP.To4() != nil {
|
||||
if (ipNet.Contains(ipnet.IP)) { match++ }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (match==0) { PE("access violation, permission denied"); os.Exit(1) }
|
||||
}
|
||||
|
||||
|
||||
func Enc(str string) string { // ----------------------------------------------------------------- encode string
|
||||
enc, _ := basex.NewEncoding(Db64(CHRS))
|
||||
return enc.Encode([]byte(Rndstr(2) + str))
|
||||
|
||||
Reference in New Issue
Block a user