如何存储 DNS 记录(Go 权威名称服务器)

huangapple go评论98阅读模式
英文:

How to store DNS records (Go authoritative name server)

问题

我需要使用miekg/dns包部署一个权威名称服务器,它几乎符合我的要求,但我找不到如何存储/持久化记录(即在磁盘上)。目前它似乎将所有内容存储在一个映射中,但我猜想当服务器关闭时,所有内容都会消失。我是否遗漏了什么,或者有没有一种简单的方法来插入一个持久化存储引擎?

英文:

I'm need to deploy an authoritative name server using and I've found miekg/dns package to almost fit the bill but I can't find how to store/persist records (i.e. on disk ). Currently it seems to store everything in a map but I guess it's all gone when the server is shut down. Is there anything I'm missing or an easy way to plugin a persistent storage engine ?

答案1

得分: 2

miekg/dns是一个库,而不是一个完全功能的DNS服务器。它内置了对RFC 1035区域文件的支持(最初由bind使用):zscan.go用于解析区域文件,zgenerate.go用于生成区域字符串。

如果你正在寻找基于这个库的完整DNS服务器,请查看README中的Users部分,或者看一下基于该库的discodns服务器,该服务器从etcd中读取区域。

英文:

miekg/dns is a library, not a fully functional DNS-server. It has built in support of RFC 1035 zone files (originally used by bind): zscan.go to parse zone file and zgenerate.go to generate zone string.

If you're looking for a complete DNS-server based on this library check Users section in README or take a look to discodns server based on the library that reads zones from etcd.

答案2

得分: 0

最简单的解决方案,我认为是使用Redis,它有几个可用的库。即使这不是你的长期解决方案,它在原型设计中表现良好。从那里,你只需要将你的数据序列化/反序列化为string/[]byte,并编写一个简单的缓存层,加载保存的状态并在发生更改时推送。

英文:

Easiest solution, IMO, is Redis, which has a few libs available. Even if this isn't your long term solution, it works well for prototyping. From there you just need to serialize/deserialize your data into/from a string/[]byte and write a simple caching layer that loads a saved state and pushes changes when they happen.

huangapple
  • 本文由 发表于 2015年9月30日 00:36:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/32849344.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定