Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > alt.comp.os.windows-10 > #96171
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Don Kuenz, KB7RPU <g@crcomp.net> |
| Newsgroups | alt.comp.os.windows-10, alt.sources |
| Subject | Re: Hosts file entries. |
| Date | Wed, 14 Aug 2019 22:34:58 -0000 (UTC) |
| Organization | A noiseless patient Spider |
| Lines | 184 |
| Message-ID | <20190814f@crcomp.net> (permalink) |
| References | <rf09lepjaifj6if6hqs42js9qc2v3qg7bl@4ax.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Date | Wed, 14 Aug 2019 22:34:58 -0000 (UTC) |
| Injection-Info | reader02.eternal-september.org; posting-host="9f9e17e672165c7ddd96a4c5d43480a1"; logging-data="22742"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/8DP6nq6YTLAAoV4TO7LN8" |
| Cancel-Lock | sha1:oL10s06Q7KUCmskci4/NnsBt5Ic= |
| Xref | csiph.com alt.comp.os.windows-10:96171 alt.sources:1016 |
Cross-posted to 2 groups.
Show key headers only | View raw
Peter Jason <pj@jostle.com> wrote:
> I am using the hosts file to block unwanted Internet sites, and the
> following works so far. Win10 1903
>
> *******************************
> # Copyright (c) 1993-2009 Microsoft Corp.
> #
> # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
> #
> # This file contains the mappings of IP addresses to host names. Each
> # entry should be kept on an individual line. The IP address should
> # be placed in the first column followed by the corresponding host
> name.
> # The IP address and the host name should be separated by at least one
> # space.
> #
> # Additionally, comments (such as these) may be inserted on individual
> # lines or following the machine name denoted by a '#' symbol.
> #
> # For example:
> #
> # 102.54.94.97 rhino.acme.com # source server
> # 38.25.63.10 x.acme.com # x client host
>
> # localhost name resolution is handled within DNS itself.
> # 127.0.0.1 localhost
> # ::1 localhost
>
> 127.0.0.1 www.expressvpn.com
> 127.0.0.1 expressvpn.com
> 127.0.0.1 www.ladbrokes.com.au
> 127.0.0.1 ladbrokes.com.au
> 127.0.0.1 www.get-express-vpn.com
> 127.0.0.1 get-express-vpn.com
> 127.0.0.1 www.drazens.com
> 127.0.0.1 drazens.com
> 127.0.0.1 www.nutaku.net
> 127.0.0.1 nutaku.com
> 127.0.0.1 www.trazens.com
> 127.0.0.1 trazens.com
> 127.0.0.1 www.velocecdn.com
> 127.0.0.1 velocecdn.com
>
> ***********************************************************
>
> Is this the correct way to do it; should some entries be on the same
> line?
That's correct. In ancient days WXP took forever to timeout. So this
program below was written by me to correct the situation. Although it
used VC back in the day, it ought to be simple enough to port my app to
cygwin WIN32.
------------------------------------------------------------------------
#include <windows.h>
#include <process.h>
#include <stdio.h>
#include <time.h>
#define WM_USER_OPEN_IN_OUT WM_USER + 100
#define WM_USER_DO_XCOPY WM_USER + 101
HICON hIconState;
HINSTANCE hinst;
HWND hwnd;
static TCHAR szAppName[] = TEXT("CRCBack");
void thread(PVOID pvoid);
LRESULT CALLBACK wndProc(HWND, UINT, WPARAM, LPARAM);
void thread(PVOID pvoid)
{
char buf[BUFLEN];
int bufLen;
char msg404[] = {
"HTTP/1.1 404 Not Found\r\n"
"Connection: close\r\n"
"\r\n"
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n"
"<HTML><HEAD>\n"
"<TITLE>404 Not Found</TITLE>\n"
"</HEAD><BODY>\n"
"<H1>Not Found</H1>\n"
"The requested URL was not found on this server.<P>\n"
"<HR>\n"
"<ADDRESS>send404 server at 127.0.0.1 Port 80</ADDRESS>\n"
"</BODY></HTML>\n\x0"
};
SOCKET sConnect;
for (;;) {
/* wait for next connection */
sConnect = accept(s, NULL, NULL);
if (sConnect == INVALID_SOCKET) {
break;
}
/* receive GET message */
if ((bufLen = recv(sConnect, buf, BUFLEN, 0)) < 0) {
break;
}
/* send 404 message */
if (send(sConnect, msg404, sizeof(msg404), 0) < 0) {
break;
}
/* close connection */
closesocket(sConnect);
}
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
MSG msg;
WNDCLASSA wndclass;
hinst = hInstance;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = wndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
if (!RegisterClass(&wndclass)) {
MessageBox (NULL, TEXT("This program requires Windows NT!"),
szAppName, MB_ICONERROR);
return 0;
}
hwnd = CreateWindow(szAppName, TEXT ("CRCBack"), WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL);
//ShowWindow(hwnd, SW_SHOW);
//UpdateWindow(hwnd);
PostMessage(hwnd, WM_USER_OPEN_IN_OUT, 0, 0);
PostMessage(hwnd, WM_USER_DO_XCOPY, 0, 0);
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK wndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
case WM_CLOSE:
break;
case WM_CREATE:
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_NEXT_XCOPY:
if (initSocket() == 0) {
_beginthread(thread, 0, NULL);
}
return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
------------------------------------------------------------------------
Thank you, 73,
--
Don Kuenz KB7RPU
There was a young lady named Bright Whose speed was far faster than light;
She set out one day In a relative way And returned on the previous night.
Back to alt.comp.os.windows-10 | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Hosts file entries. Peter Jason <pj@jostle.com> - 2019-08-15 07:52 +1000
Re: Hosts file entries. "Mayayana" <mayayana@invalid.nospam> - 2019-08-14 18:14 -0400
Re: Hosts file entries. Don Kuenz, KB7RPU <g@crcomp.net> - 2019-08-14 22:34 +0000
Re: Hosts file entries. Arlen George Holder <arlinggeorgeholder@nospam.net> - 2019-08-15 00:29 +0000
Re: Hosts file entries. "s|b" <me@privacy.invalid> - 2019-08-15 18:29 +0200
Re: Hosts file entries. "Carlos E.R." <robin_listas@es.invalid> - 2019-08-16 12:12 +0200
Re: Hosts file entries. Peter Jason <pj@jostle.com> - 2019-08-16 11:36 +1000
Re: Hosts file entries. Paul <nospam@needed.invalid> - 2019-08-16 03:39 -0400
Re: Hosts file entries. notX <no.email@dummy.invalid> - 2019-08-16 11:42 -0500
Re: Hosts file entries. MikeS <MikeS@fred.com> - 2019-08-16 17:39 +0100
Re: Hosts file entries. Rabid Robot <rabid@rob.ot> - 2019-08-16 13:48 -0400
csiph-web