Example #1
0
func aflist_update(data []byte) {
	AfList.Lock()
	defer AfList.Unlock()
	lines := bytes.Split(data, []byte("\n"))
	for _, line := range lines {
		m := aflist_re.FindSubmatch(line)
		if m != nil {
			k := m[1]
			v := m[2]
			//			AfList.AppendUnsafe(string(k), nopfs.NewFile(v))
			if bytes.HasPrefix(k, []byte("rxpower")) {
				AfList.AppendUnsafe(string(k), nopfs.NewFile(v))
			}
		}

	}
	AfList.AppendUnsafe("all", nopfs.NewFile(data))
}
Example #2
0
func main() {
	flag.Parse()

	root := nopfs.NewDir()
	root.Append("README.txt", nopfs.NewFile([]byte(readme_top)))

	host := nopfs.NewAnyDir()
	root.Append("host", host)
	host.Static("README.txt", nopfs.NewFile([]byte(readme_host)))
	host.Static("clear", &nopfs.Ctl{Writer: nopfs.AnyDirCtlReset})

	host.Append("icmp", icmp.Dir)
	host.Append("dns", dns.Dir)

	sfs := new(nopfs.NopSrv)
	sfs.Debuglevel = *debug
	sfs.Root = root
	sfs.Start(sfs)
	err := sfs.StartNetListener("tcp", *addr)
	if err != nil {
		log.Fatalf("%s", err)
	}
}
Example #3
0
File: dns.go Project: wwaites/nopfs
===========================

This directory contains name service routines. Reading the files
results in name resolution using the server's local mechanism --
usually /etc/hosts followed by DNS.

  - addr    Look up the IPv4/IPv6 address for a name
  - cname   Look up the canonical version of a name
  - name    Reverse look up of the name that corresponds to an
            address
  - mx      Look up the mail exchanger corresponding for a domain
  - ns      Look up the DNS servers for a domain
  - txt     Look up any text records for a name

`
var Readme nopfs.Dispatcher = nopfs.NewFile([]byte(readme_dns))

func addr(host string) (data []byte, err error) {
	addrs, err := net.LookupHost(host)
	if err != nil {
		err = os.ErrNotExist
		return
	}

	buf := bytes.NewBuffer(make([]byte, 0, len(addrs)*16))
	for _, ip := range addrs {
		buf.WriteString(ip)
		buf.WriteByte('\n')
	}
	data = buf.Bytes()
	return