소스 검색

made and edit to the makefile and removed recursion depth limiter

AETH-erial 10 달 전
부모
커밋
34aed7afa9
3개의 변경된 파일9개의 추가작업 그리고 28개의 파일을 삭제
  1. 6 2
      Makefile
  2. 0 19
      cmd/kyoketsu-web/kyoketsu-web.go
  3. 3 7
      pkg/local.go

+ 6 - 2
Makefile

@@ -1,4 +1,4 @@
-.PHONY: build format 
+.PHONY: build format test 
 
 KYOKETSU = kyoketsu
 
@@ -7,11 +7,15 @@ build:
 
 
 format:
-	go fmt ,/...
+	go fmt ./...
 
 install:
+	sudo rm -f /usr/local/bin/$(KYOKETSU) && \
 	sudo mv ./build/linux/$(KYOKETSU)/$(KYOKETSU) /usr/local/bin && sudo chmod u+x /usr/local/bin/$(KYOKETSU) 
 
 
+test:
+	go test ./...
+
 
 

+ 0 - 19
cmd/kyoketsu-web/kyoketsu-web.go

@@ -1,20 +1 @@
 package main
-
-import (
-	"fmt"
-	"log"
-	"os"
-
-	kyoketsu "git.aetherial.dev/aeth/kyoketsu/pkg"
-)
-
-func main() {
-
-	addrs, err := kyoketsu.GetNetworkAddresses(os.Args[1])
-	if err != nil {
-		log.Fatal(err)
-	}
-
-	fmt.Printf("%+v\n", addrs)
-
-}

+ 3 - 7
pkg/local.go

@@ -62,11 +62,7 @@ Recursive function to get all of the IPv4 addresses for each IPv4 network that t
 		:param max: This is safety feature to prevent stack overflows, so you can manually set the depth to
 		            call the function
 */
-func addressRecurse(ipmap *IpSubnetMapper, max int) {
-
-	if len(ipmap.Ipv4s) > max {
-		return
-	}
+func addressRecurse(ipmap *IpSubnetMapper) {
 
 	next := getNextAddr(ipmap.Current.String())
 
@@ -79,7 +75,7 @@ func addressRecurse(ipmap *IpSubnetMapper, max int) {
 	ipmap.Current = net.ParseIP(next)
 
 	ipmap.Ipv4s = append(ipmap.Ipv4s, net.ParseIP(next))
-	addressRecurse(ipmap, max)
+	addressRecurse(ipmap)
 }
 
 /*
@@ -102,7 +98,7 @@ func GetNetworkAddresses(addr string) (*IpSubnetMapper, error) {
 	ipmap.NetworkAddr = ip.Mask(net.Mask)
 	ipmap.Mask = mask
 	ipmap.Current = ip.Mask(net.Mask)
-	addressRecurse(ipmap, 65535)
+	addressRecurse(ipmap)
 
 	return ipmap, nil