aboutsummaryrefslogtreecommitdiffstats
path: root/src/libexec/peerip.c
diff options
context:
space:
mode:
authorEpoch Qwert <epoch@53flpnlls43fcguy.onion>2014-12-24 07:31:09 -0600
committerEpoch Qwert <epoch@53flpnlls43fcguy.onion>2014-12-24 07:31:09 -0600
commit9750d3845bd5bbc2e5e76134b8c4a902faa9bce9 (patch)
tree1b38f9a5a0e80eee6be6d93d33aeab0dd9ca641b /src/libexec/peerip.c
parent612926651db0c13fa9f45f58764b56ab132b211c (diff)
downloadmisc-9750d3845bd5bbc2e5e76134b8c4a902faa9bce9.tar.gz
misc-9750d3845bd5bbc2e5e76134b8c4a902faa9bce9.zip
added IPv6 support to hop0, peerip, and gopherd.sh
gopherd.sh got lots of other updates too. speed is for measuring how many lines per second your pipes can do.
Diffstat (limited to 'src/libexec/peerip.c')
-rw-r--r--src/libexec/peerip.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/libexec/peerip.c b/src/libexec/peerip.c
index 9298f87..6bcf1f1 100644
--- a/src/libexec/peerip.c
+++ b/src/libexec/peerip.c
@@ -1,16 +1,20 @@
#include <stdio.h>
#include <sys/socket.h>
#include <netdb.h>
+#include <netinet/in.h>
int main(int argc,char *argv[]) {
int i;
- struct sockaddr sa;
- int sl=sizeof(sa);
+ struct sockaddr_in6 sa6;
+ int err;
+ int sl=sizeof(sa6);
char h[NI_MAXHOST], s[NI_MAXSERV];
- getpeername(0,&sa,&sl);
- if(getnameinfo(&sa,sl,h,sizeof(h),s,sizeof(s),NI_NUMERICHOST|NI_NUMERICSERV)) {
+ if(getpeername(0,(struct sockaddr *)&sa6,&sl) == -1) {
return 1;
}
+ if(err=getnameinfo((struct sockaddr *)&sa6,sl,h,sizeof(h),s,sizeof(s),NI_NUMERICHOST|NI_NUMERICSERV)) {
+ return 2;
+ }
puts(h);
puts(s);
return 0;