NodeInfo server implemented in Go.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

35 lignes
651 B

  1. package nodeinfo
  2. const (
  3. profileVer = "2.0"
  4. profile = "http://nodeinfo.diaspora.software/ns/schema/" + profileVer
  5. )
  6. type Service struct {
  7. InfoURL string
  8. Info NodeInfo
  9. resolver Resolver
  10. }
  11. func NewService(cfg Config, r Resolver) *Service {
  12. return &Service{
  13. InfoURL: cfg.BaseURL + cfg.InfoURL,
  14. Info: NodeInfo{
  15. Metadata: cfg.Metadata,
  16. Protocols: cfg.Protocols,
  17. Services: cfg.Services,
  18. Software: cfg.Software,
  19. },
  20. resolver: r,
  21. }
  22. }
  23. func (s Service) BuildInfo() NodeInfo {
  24. ni := s.Info
  25. ni.OpenRegistrations, _ = s.resolver.IsOpenRegistration()
  26. ni.Usage, _ = s.resolver.Usage()
  27. ni.Version = profileVer
  28. return ni
  29. }