Results 1 to 10 of 165

Thread: VPN Forum access and IP addresse Tests

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,521
    Rep Power
    10
    Some notes in support of these Threads
    http://www.eileenslounge.com/viewtopic.php?f=18&t=33775
    http://www.eileenslounge.com/viewtop...d7141c#p262009
    http://www.excelfox.com/forum/showth...ll=1#post11570
    http://www.excelfox.com/forum/showth...ll=1#post11608
    http://www.excelfox.com/forum/showth...ll=1#post11803




    VPN and IP Addresses
    Some of the initial investigations into testing VPN and in looking at problems showed that it was useful to be able to monitor various IP addresses.
    The main (Public) address, as already discussed, ( http://www.excelfox.com/forum/showth...ll=1#post11597 ) , is of course important to know . There is also a "local host", which more typically is set to the same number for everyone, (127.0.0.1 ). This is a number which conventionally is used to allow direct access to network aspects of your computer which might otherwise be accessed externally in some way or another. A characteristic of VPN software is that it manipulate your computer in a way such that, amongst other things , this number will change to the internal address used at your VPN provider to identify you within their system. It is part of the trickery in the Client software, that you "looking at yourself" gets manipulated into looking somewhere else. The provider in some ways is then in control of your computer allowing them to give the impression that your computer is physically somewhere else: Part of your computer "Soul" is with them.

    Public address
    Manually this is achieved typically by visiting various sites that provide you with this information. The automated way still needs to use such sites. The reason for this is that you need to be able to get the information by accessing yourself in the way that another computer connected to the internet "gets at you". Part of this process involves obtaining your public address as you communicate initially with them. We could scrap any site offering the service and pick out the IP address information.
    We can simplify the coding to do this by accessing a site available which only gives the IP information, and which shows as the website that you "see" just that IP address number.
    So for example if you type in your browser URL bar, http://myip.dnsomatic.com/ , then all you will see is the IP address. You will even see only that if you are in Google Chrome Browser and right click and view the Page Source
    Page Source myip dnsomatic .JPG : https://imgur.com/uceUKE4 Attachment 2567
    Page Source myip dnsomatic .JPG

    This information will be the entire .responseText received back. In normal scrapping coding you might feed this supplied text string into an object model software which allows you to then pick out using OOP type techniques what you want. If we use the site http://myip.dnsomatic.com/ , we don't need to take that extra step, and can simply view the entire .responseText , as this is the exact info we want.

    ( I found that sometimes the first one or few attemps did not work in the next coding, but almost always after a few attemopts it worked. So the recursion technique is used to call the Function a few times , if necerssary )

    Code:
    Option Explicit
    Sub TestPubicIP()
    Dim strIP As String
     Call PubicIP(strIP)
     MsgBox prompt:=strIP
     'Call WtchaGot(strIP)
    End Sub
    ' Because we have ByRef PublicIP  , the is effectively taking the variable  strIP  into the function, and similarly in the  recursion Call line  that variable is taken.  Hopefull in one of the 5 attepts at running the Function  it will be filled.. We don't actually fill the pseudo variable  PubicIP  so no value is returned directly by the Function. (So we could have used a Sub()routine instead)  To get a returned value we look at the value in  strIP  after runing the routine , because , as said, hopefully that particular variable will have been added to
    Function PubicIP(ByRef PublicIP As String, Optional ByVal Tries As Long) As String
        If Tries = 5 Then Exit Function
     On Error GoTo Bed
        With CreateObject("msxml2.xmlhttp")
         .Open "GET", "http://myip.dnsomatic.com", True ' 'just preparing the request type, how and what type... "The True/False argument of the HTTP Request is the Asynchronous mode flag. If set False then control is immediately returns to VBA after Send is executed. If set True then control is returned to VBA after the server has sent back a response.
         'No extra info here for type GET
         '.setRequestHeader bstrheader:="Ploppy", bstrvalue:="Poo"
         .setRequestHeader bstrheader:="If-Modified-Since", bstrvalue:="Sat, 1 Jan 2000 00:00:00 GMT" '  https://www.autohotkey.com/boards/viewtopic.php?t=9554  ---   It will caching the contents of the URL page. Which means if you request the same URL more than once, you always get the same responseText even the website changes text every time. This line is a workaround : Set cache related headers.
         .send ' varBody:= ' No extra info for type GET. .send actually makes the request
            While .readyState <> 4: DoEvents: Wend ' Allow other processes to run while the web page loads. Think this is part of the True option
        Dim PageSrc As String: Let PageSrc = .responseText ' Save the HTML code in the (Global) variable. ': Range("P1").Value = PageSrc 'For me for a print out copy to text file etc.    The responseText property returns the information requested by the Open method as a text string
        End With
     Let PublicIP = PageSrc: ' Debug.Print PubicIP
     'Call WtchaGot(PubicIP)
         If PublicIP = "" Then Call PubicIP(PublicIP, Tries + 1) ' Recursion Call line. I do this because sometines it seems to need more than one try before it works
    Exit Function
    Bed:
     Let PubicIP = Err.Number & ":  " & Err.Description: Debug.Print PubicIP
    End Function

    As an alternative , I have below a similar coding. It gets the page source from another site which shows your IP address. I found when looking at the page source in Google Chrome, that I could see the IP address conveniently showing between two simple text lines :
    Page Source whatismyipaddress_com .JPG : https://imgur.com/LSvORAe
    Page Source whatismyipaddress_com .JPG

    To VBA ( or most computer things), that text looks like a long string, and at that point we can imagine that it looks to the computer like any one of these 3 representations
    ……. ipt -->" & vbLf & "87" & "." & "101" & "." & "95" & "." & "204" & vbLf & "……..
    …….ipt --> vbLf 87.101.95.204 vbLf …….

    …….ipt --> vbLf
    87.101.95.204 vbLf
    …….


    We apply some simple VBA strings manipulation techniques to extract just the IP address number
    Code:
    '
    Sub TestPubicIPwhatismyipaddress_com()
    Dim strIP As String
     Let strIP = PubicIPwhatismyipaddress_com
     MsgBox prompt:=strIP
    End Sub
    Function PubicIPwhatismyipaddress_com() As String
     On Error GoTo Bed
        With CreateObject("msxml2.xmlhttp")
         .Open "GET", "https://whatismyipaddress.com/de/meine-ip", False ' 'just preparing the request type, how and what type... "The True/False argument of the HTTP Request is the Asynchronous mode flag. If set False then control is immediately returns to VBA after Send is executed. If set True then control is returned to VBA after the server has sent back a response.
         'No extra info here for type GET
         '.setRequestHeader bstrheader:="Ploppy", bstrvalue:="Poo"
         .setRequestHeader bstrheader:="If-Modified-Since", bstrvalue:="Sat, 1 Jan 2000 00:00:00 GMT" '  https://www.autohotkey.com/boards/viewtopic.php?t=9554  ---   It will caching the contents of the URL page. Which means if you request the same URL more than once, you always get the same responseText even the website changes text every time. This line is a workaround : Set cache related headers.
         .send ' varBody:= ' No extra info for type GET. .send actually makes the request
            While .READYSTATE <> 4: DoEvents: Wend ' Allow other processes to run while the web page loads. Think this is part of the True option
        Dim PageSrc As String: Let PageSrc = .responsetext ' Save the HTML code in the (Global) variable. ': Range("P1").Value = PageSrc 'For me for a print out copy to text file etc.    The responseText property returns the information requested by the Open method as a text string
        End With
     Let PubicIPwhatismyipaddress_com = PageSrc: ' Debug.Print PubicIPwhatismyipaddress_com
    Dim IPadres As String, posIPadres1 As Long, posIPadres2 As Long
     Let posIPadres1 = InStr(1, PageSrc, "", vbBinaryCompare)  '      Screenshot --->   Page Source whatismyipaddress_com .JPG : https://imgur.com/LSvORAe
     Let posIPadres2 = InStr(posIPadres1 + 1, PageSrc, "", vbBinaryCompare)
     Let PubicIPwhatismyipaddress_com = Mid(PageSrc, posIPadres1 + 23, ((posIPadres2 - 1) - (posIPadres1 + 23)))
     Call WtchaGot(PubicIPwhatismyipaddress_com)
    Exit Function
    Bed:
     Let PubicIPwhatismyipaddress_com = Err.Number & ":  " & Err.Description: Debug.Print PubicIPwhatismyipaddress_com
    End Function



    Local Host address and computer name in the next post




    Last edited by DocAElstein; 01-07-2020 at 02:46 AM.

Similar Threads

  1. Table Tests. And Thread Copy Tests No Reply needed
    By DocAElstein in forum Test Area
    Replies: 1
    Last Post: 11-20-2018, 01:11 PM
  2. Table Tests. And Thread Copy Tests No Reply needed
    By DocAElstein in forum Test Area
    Replies: 1
    Last Post: 11-20-2018, 01:11 PM
  3. New Forum Style
    By Admin in forum Public News
    Replies: 2
    Last Post: 05-16-2014, 11:34 AM
  4. Forum performances
    By Loser Who Got Kicked Where The Sun Don't Shine in forum Greetings and Inception
    Replies: 1
    Last Post: 01-03-2013, 07:50 PM
  5. Replies: 2
    Last Post: 09-08-2012, 10:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •