mirror of https://github.com/namecoin/ncdns
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.9 KiB
Go
68 lines
1.9 KiB
Go
6 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
|
||
|
"github.com/hlandau/xlog"
|
||
2 years ago
|
"github.com/btcsuite/btcd/rpcclient"
|
||
6 years ago
|
"gopkg.in/hlandau/easyconfig.v1"
|
||
|
"gopkg.in/hlandau/easyconfig.v1/cflag"
|
||
|
|
||
|
"github.com/namecoin/ncdns/namecoin"
|
||
|
"github.com/namecoin/ncdns/ncdumpzone"
|
||
|
)
|
||
|
|
||
|
var log, _ = xlog.New("ncdumpzone-main")
|
||
|
|
||
|
var (
|
||
|
flagGroup = cflag.NewGroup(nil, "ncdumpzone")
|
||
|
rpchostFlag = cflag.String(flagGroup, "namecoinrpcaddress",
|
||
|
"127.0.0.1:8336", "Namecoin RPC host:port")
|
||
|
rpcuserFlag = cflag.String(flagGroup, "namecoinrpcusername", "",
|
||
|
"Namecoin RPC username")
|
||
|
rpcpassFlag = cflag.String(flagGroup, "namecoinrpcpassword", "",
|
||
|
"Namecoin RPC password")
|
||
5 years ago
|
rpccookiepathFlag = cflag.String(flagGroup, "namecoinrpccookiepath", "",
|
||
|
"Namecoin RPC cookie path (used if password is unspecified)")
|
||
6 years ago
|
formatFlag = cflag.String(flagGroup, "format", "zonefile", "Output "+
|
||
|
"format. \"zonefile\" = DNS zone file. "+
|
||
5 years ago
|
"\"firefox-override\" = Firefox cert_override.txt format. "+
|
||
|
"\"url-list\" = URL list.")
|
||
6 years ago
|
)
|
||
|
|
||
5 years ago
|
var conn *namecoin.Client
|
||
6 years ago
|
|
||
|
var config = easyconfig.Configurator{
|
||
|
ProgramName: "ncdumpzone",
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
err := config.Parse(nil)
|
||
|
if err != nil {
|
||
|
log.Fatalf("Couldn't parse configuration: %s", err)
|
||
|
}
|
||
|
|
||
5 years ago
|
// Connect to local namecoin core RPC server using HTTP POST mode.
|
||
|
connCfg := &rpcclient.ConnConfig{
|
||
|
Host: rpchostFlag.Value(),
|
||
|
User: rpcuserFlag.Value(),
|
||
|
Pass: rpcpassFlag.Value(),
|
||
|
CookiePath: rpccookiepathFlag.Value(),
|
||
|
HTTPPostMode: true, // Namecoin core only supports HTTP POST mode
|
||
|
DisableTLS: true, // Namecoin core does not provide TLS by default
|
||
|
}
|
||
|
|
||
|
// Notice the notification parameter is nil since notifications are
|
||
|
// not supported in HTTP POST mode.
|
||
|
conn, err = namecoin.New(connCfg, nil)
|
||
|
if err != nil {
|
||
|
log.Fatalf("Couldn't create RPC client: %s", err)
|
||
|
}
|
||
|
defer conn.Shutdown()
|
||
6 years ago
|
|
||
|
err = ncdumpzone.Dump(conn, os.Stdout, formatFlag.Value())
|
||
|
if err != nil {
|
||
|
log.Fatalf("Couldn't dump zone: %s", err)
|
||
|
}
|
||
|
}
|