Index: dlls/winsock/socket.c
===================================================================
RCS file: /home/wine/wine/dlls/winsock/socket.c,v
retrieving revision 1.202
diff -b -B -c -r1.202 socket.c
*** dlls/winsock/socket.c	9 Dec 2005 12:19:48 -0000	1.202
--- dlls/winsock/socket.c	12 Dec 2005 15:25:49 -0000
***************
*** 2927,2932 ****
--- 2927,2993 ----
      return retval;
  }
  
+ 
+ /***********************************************************************
+  *		GetPublicIP		(Internal)
+  *
+  *   Tries to guess the public IP-Adress by enumerating the available Interfaces
+  *   target needs to be a buffer with the maximum size given in "size"
+  */
+ 
+ 
+ BOOL GetPublicIP(char* target,int size)
+ {
+     char buff[1024];
+     char buffer[1024];
+     struct ifconf ifc;
+     struct ifreq *ifr;
+     int skfd;
+     int i;
+ 
+ 
+     skfd = socket(AF_INET, SOCK_DGRAM, 0);
+     if (skfd < 0)
+     {
+         WARN("A socket could not be created");
+         return FALSE;
+     }
+ 
+ 
+     ifc.ifc_len = sizeof(buff);
+     ifc.ifc_buf = buff;
+     if (ioctl(skfd, SIOCGIFCONF, &ifc) < 0)
+     {
+         WARN("ioctl(SIOCGIFCONF) failed");
+         return FALSE;
+     }
+ 
+ 
+     ifr = ifc.ifc_req;
+ 
+ 
+     for (i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++)
+     {
+         struct sockaddr_in* addr=(struct sockaddr_in*)&ifr[i].ifr_addr;
+         unsigned char* ip = ((unsigned char*)&addr->sin_addr);
+ 		
+         if(strcmp(ifr[i].ifr_name,"lo")==0)continue;   //Exclude loopback-device by Name "lo"
+ 		
+         if(ip[0]==127&&ip[1]==0&&ip[2]==0&&ip[3]==0)continue; //Exclude 127.0.0.1
+ 		
+         sprintf(buffer,"%i.%i.%i.%i", (int)ip[0],(int)ip[1],(int)ip[2],(int)ip[3]);
+ 
+         if(size>=strlen(buffer))strcpy(target,buffer);
+ 		
+         return TRUE;
+     }
+ 
+ 
+     return FALSE;
+ }
+ 
+ 
+ 
  /***********************************************************************
   *		gethostbyname		(WS2_32.52)
   */
***************
*** 2930,2937 ****
--- 2991,3003 ----
  /***********************************************************************
   *		gethostbyname		(WS2_32.52)
   */
+ 
  struct WS_hostent* WINAPI WS_gethostbyname(const char* name)
  {
+     char myname[1000];
+ 
+     struct in_addr newaddr;
+ 
      struct WS_hostent *retval = NULL;
      struct hostent*     host;
  #ifdef  HAVE_LINUX_GETHOSTBYNAME_R_6
***************
*** 2941,2946 ****
--- 3007,3015 ----
      int locerr = ENOBUFS;
  #endif
      char buf[100];
+ 
+     gethostname(myname,(size_t)1000);
+ 
      if( !name) {
          name = buf;
          if( gethostname( buf, 100) == -1) {
***************
*** 2961,2969 ****
  #else
      EnterCriticalSection( &csWSgetXXXbyYYY );
      host = gethostbyname(name);
      if (!host) SetLastError((h_errno < 0) ? wsaErrno() : wsaHerrno(h_errno));
  #endif
!     if (host) retval = WS_dup_he(host);
  #ifdef  HAVE_LINUX_GETHOSTBYNAME_R_6
      HeapFree(GetProcessHeap(),0,extrabuf);
  #else
--- 3035,3063 ----
  #else
      EnterCriticalSection( &csWSgetXXXbyYYY );
      host = gethostbyname(name);
+     
      if (!host) SetLastError((h_errno < 0) ? wsaErrno() : wsaHerrno(h_errno));
  #endif
!     if (host&&((struct in_addr *)host->h_addr_list[0])!=NULL)
! {
!     if(strcmp(myname,name)==0||strcmp("localhost",name)==0||strcmp(inet_ntoa(*((struct in_addr *)host->h_addr_list[0])),"127.0.0.1")==0)
!     {
!                 //Replace the gotten Adress
!         char buffer[400];
!         if(GetPublicIP(buffer,400))
!         {
!             inet_aton(buffer,&newaddr);
!                 
!             memcpy(((struct in_addr *)host->h_addr_list[0]),&newaddr,4);
!                     
!             TRACE("Using %s as public Adress\n",inet_ntoa(*((struct in_addr *)host->h_addr_list[0])));
!         }else{
!             WARN("Public IP-Adress could not be recognized");
!         }
!     }
! 
!     retval = WS_dup_he(host);
! }
  #ifdef  HAVE_LINUX_GETHOSTBYNAME_R_6
      HeapFree(GetProcessHeap(),0,extrabuf);
  #else
