1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
--- valknut/dcoptions.cpp.orig 2014-12-02 20:28:59.039798842 +0100
+++ valknut/dcoptions.cpp 2014-12-02 22:25:06.352312671 +0100
@@ -808,15 +808,18 @@
{
PushButton_GETINTERNETIP->setEnabled(false);
- QHttpRequestHeader header( "GET", "/ip.php" );
- header.setValue( "Host", "wxdcgui.sourceforge.net" );
+ //QHttpRequestHeader header( "GET", "/ip.php" );
+ QHttpRequestHeader header( "GET", "/" );
+ //header.setValue( "Host", "wxdcgui.sourceforge.net" );
+ header.setValue( "Host", "www.myip.se" );
QString useragent = QString("Valknut/") + PACKAGE_VERSION;
//printf("User-Agent=%s\n", useragent.toAscii().constData());
header.setValue( "User-Agent", useragent );
m_pHttp = new QHttp();
connect( m_pHttp, SIGNAL(done(bool)), this, SLOT(slotGotInternetIP(bool)) );
- m_pHttp->setHost( "wxdcgui.sourceforge.net" );
+ //m_pHttp->setHost( "wxdcgui.sourceforge.net" );
+ m_pHttp->setHost( "www.myip.se" );
m_pHttp->request( header );
}
@@ -834,20 +837,25 @@
else
{
QString html = QString(m_pHttp->readAll());
- int start = html.indexOf("<ip>");
- int end = html.indexOf("</ip>",start);
-
+
+ int start = html.indexOf("<b>");
+ // We need the 2nd "bold" (<b>) attribute
+ start = html.indexOf("<b>",start+3);
+ int end = html.indexOf("</b>",start);
+
if ( ( start == -1 ) || ( end < start ) )
{
QMessageBox::warning(
this,
tr("Get Internet IP"),
- tr("Unexpected response from ") + "http://wxdcgui.sourceforge.net"
+ tr("Unexpected response from ") + "http://www.myip.se"
+ // tr("Unexpected response from ") + "http://wxdcgui.sourceforge.net"
);
}
else
{
- start += 10;
+ //start += 10; // wxgui.sourceforge.net
+ start += 21; // www.myip.se
QString ip = html.mid( start, end - start );
if ( QHostAddress().setAddress(ip) )
|