Guest User

Untitled

a guest
Jan 23rd, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. "log"
  6. "net"
  7. )
  8.  
  9. func main() {
  10. ip, ipnet, err := net.ParseCIDR("62.76.47.12/28")
  11. if err != nil {
  12. log.Fatal(err)
  13. }
  14. for ip := ip.Mask(ipnet.Mask); ipnet.Contains(ip); inc(ip) {
  15. fmt.Println(ip)
  16. }
  17. }
  18.  
  19. func inc(ip net.IP) {
  20. for j := len(ip)-1; j>=0; j-- {
  21. ip[j]++
  22. if ip[j] > 0 {
  23. break
  24. }
  25. }
  26. }
Add Comment
Please, Sign In to add comment