Highly-opinionated (ex-bullshit-free) MTPROTO proxy for Telegram. If you use v1.0 or upgrade broke you proxy, please read the chapter Version 2
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.

type_ip.go 617B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package config
  2. import (
  3. "fmt"
  4. "net"
  5. )
  6. type TypeIP struct {
  7. value net.IP
  8. }
  9. func (c *TypeIP) UnmarshalText(data []byte) error {
  10. if len(data) == 0 {
  11. return nil
  12. }
  13. ip := net.ParseIP(string(data))
  14. if ip == nil {
  15. return fmt.Errorf("incorrect ip address: %s", string(data))
  16. }
  17. c.value = ip
  18. return nil
  19. }
  20. func (c *TypeIP) MarshalText() ([]byte, error) {
  21. return []byte(c.String()), nil
  22. }
  23. func (c TypeIP) String() string {
  24. if len(c.value) > 0 {
  25. return c.value.String()
  26. }
  27. return ""
  28. }
  29. func (c TypeIP) Value(defaultValue net.IP) net.IP {
  30. if c.value == nil {
  31. return defaultValue
  32. }
  33. return c.value
  34. }