(a net.Addr)
| 54 | } |
| 55 | |
| 56 | func addrToProto(a net.Addr) *channelzpb.Address { |
| 57 | if a == nil { |
| 58 | return nil |
| 59 | } |
| 60 | switch a.Network() { |
| 61 | case "udp": |
| 62 | // TODO: Address_OtherAddress{}. Need proto def for Value. |
| 63 | case "ip": |
| 64 | // Note zone info is discarded through the conversion. |
| 65 | return &channelzpb.Address{Address: &channelzpb.Address_TcpipAddress{TcpipAddress: &channelzpb.Address_TcpIpAddress{IpAddress: a.(*net.IPAddr).IP}}} |
| 66 | case "ip+net": |
| 67 | // Note mask info is discarded through the conversion. |
| 68 | return &channelzpb.Address{Address: &channelzpb.Address_TcpipAddress{TcpipAddress: &channelzpb.Address_TcpIpAddress{IpAddress: a.(*net.IPNet).IP}}} |
| 69 | case "tcp": |
| 70 | // Note zone info is discarded through the conversion. |
| 71 | return &channelzpb.Address{Address: &channelzpb.Address_TcpipAddress{TcpipAddress: &channelzpb.Address_TcpIpAddress{IpAddress: a.(*net.TCPAddr).IP, Port: int32(a.(*net.TCPAddr).Port)}}} |
| 72 | case "unix", "unixgram", "unixpacket": |
| 73 | return &channelzpb.Address{Address: &channelzpb.Address_UdsAddress_{UdsAddress: &channelzpb.Address_UdsAddress{Filename: a.String()}}} |
| 74 | default: |
| 75 | } |
| 76 | return &channelzpb.Address{} |
| 77 | } |
| 78 | |
| 79 | func socketToProto(skt *channelz.Socket) *channelzpb.Socket { |
| 80 | s := &channelzpb.Socket{} |
no test coverage detected