L2 Hosts Manager v1.6

Have you created a useful tool? or Do you want to get help building one? This is the right place!
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
Stealth
Posts: 8
Joined: Mon Jul 06, 2009 8:43 am

L2 Hosts Manager v1.6

Post by Stealth »

Image

L2Hosts Manager - Information

This program can help you manage your hosts file and through that file play on servers.
Each server now uses hosts which is a legal way to play on emulator servers (L2 java powered)
well this application does it all for you , you just need to enter the ip address of the server
click "add" select it and click "Write to hosts" its that easy.
This program can also help you if you join a server which has dynamic ip.In that situation
the server's ip is automatically updated on every server machine restart or network restart
on the server machine which could create a lot of problems because when the server disconnects
you need to find his ip again through his hostname and close Lineage , open your hosts and
edit them with the ip , then save hosts and re-open Lineage II which could take a lot of time
this program updates hosts to the server's ip every 30 seconds.The only thing you need to do
is to give it the server's hostname and the rest are done automatically , you don't even need to
close Lineage II.


Download link: http://www.mediafire.com/?myqi3wdcowy
Password: oq9lrm

Source:

Code: Select all

 Imports System.IOImports System.Net Public Class Form1    Public hostsfile = ""    Public website = "http://tnuke.hostei.com/forum/index.php/topic,3.0.html"    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load        DetectHosts()        Me.Text = Me.Text & " - " & website    End Sub     Sub DetectHosts()        If File.Exists("C:\windows\system32\drivers\etc\hosts") Then            hostsfile = "C:\windows\system32\drivers\etc\hosts"            Log("Hosts have been detected.")            Log("[" & hostsfile & "]")            File.SetAttributes(hostsfile, FileAttributes.Normal)        Else            hostsfile = Nothing            Log("Hosts have not been detected!")            Log("Please click the 'Find hosts' button and search for them.")            Button3.Enabled = True        End If    End Sub     Sub Log(ByVal text As String)        If TextBox1.Text.Length > 0 Then            TextBox1.Text = TextBox1.Text & vbNewLine & text        Else            TextBox1.Text = TextBox1.Text & text        End If    End Sub     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click        If TextBox1.Visible = True Then            Button1.Text = "+"            TextBox1.Visible = False            Dim point As New Point(521, 252)            Me.Size = point        ElseIf TextBox1.Visible = False Then            Button1.Text = "-"            TextBox1.Visible = True            Dim point As New Point(521, 335)            Me.Size = point        End If    End Sub     Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged        TextBox1.HideSelection = False        TextBox1.SelectionLength = 0        TextBox1.SelectionStart = Len(TextBox1.Text)        TextBox1.ScrollToCaret()    End Sub     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click        Dim o As OpenFileDialog = New OpenFileDialog        o.Filter = "All files (*.*)|*.*"        If o.ShowDialog = Windows.Forms.DialogResult.OK Then            hostsfile = o.FileName            If hostsfile.ToString.Length > 0 Then                Button3.Enabled = False            Else                Button3.Enabled = True            End If        Else            Button3.Enabled = True        End If    End Sub     Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click        Me.Close()    End Sub     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click        If TextBox2.Text.Length > 0 Then            ListBox1.Items.Add(TextBox2.Text)        Else            Log("Please enter a valid ip address.")        End If    End Sub     Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click        Try            If ListBox1.SelectedItem > 0 Then                ListBox1.Items.Remove(ListBox1.SelectedItem)            Else                Log("Please select an item.")            End If        Catch ex As Exception            ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)        End Try    End Sub     Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click        If ListBox1.SelectedItem > 0 Then            If hostsfile.ToString.Length > 0 Then                Dim o As IO.StreamWriter                If File.Exists(hostsfile) Then                    File.SetAttributes(hostsfile, FileAttributes.Normal)                    File.Delete(hostsfile)                    o = IO.File.AppendText(hostsfile)                    o.WriteLine("## L2J Hosts Manager - " & website & " ##")                    o.WriteLine("127.0.0.1      localhost")                    o.WriteLine(ListBox1.SelectedItem & "      L2authd.lineage2.com")                    o.WriteLine("216.107.250.194      nprotect.lineage2.com")                    o.WriteLine("216.107.250.194      update.nProtect.com")                    o.Close()                Else                    File.SetAttributes(hostsfile, FileAttributes.Normal)                    o = IO.File.AppendText(hostsfile)                    o.WriteLine("## L2J Hosts Manager - " & website & " ##")                    o.WriteLine("127.0.0.1      localhost")                    o.WriteLine(ListBox1.SelectedItem & " L2authd.lineage2.com")                    o.WriteLine("216.107.250.194 nprotect.lineage2.com")                    o.WriteLine("216.107.250.194 update.nProtect.com")                    o.Close()                End If            End If            Log("IP {" & ListBox1.SelectedItem & "} has been written to hosts.")        Else            Log("Please select an item.")        End If    End Sub     Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click        If TextBox3.ReadOnly = False Then            Button7.Text = "Unlock"            TextBox3.ReadOnly = True            Log("Hostname {" & TextBox3.Text & "} has been locked!")            If CheckBox1.Checked = True Then                Timer1.Start()                Log("Autoupdate is enabled!")            End If        Else            Button7.Text = "Lock"            TextBox3.ReadOnly = False            Log("Hostname {" & TextBox3.Text & "} has been unlocked!")            Timer1.Stop()            Log("Autoupdate is disabled!")        End If    End Sub     Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged        If CheckBox1.Checked = True Then            If TextBox3.TextLength > 0 And TextBox3.ReadOnly = True Then                Log("Autoupdate is enabled!")                Timer1.Start()            Else                MsgBox("Please enter a hostname to update to and then lock the textbox to continue.")                CheckBox1.Checked = False            End If        Else            Log("Autoupdate is disabled!")            Timer1.Stop()        End If    End Sub     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick        If TextBox3.TextLength > 0 And TextBox3.ReadOnly = True Then            If hostsfile.ToString.Length > 0 Then                File.SetAttributes(hostsfile, FileAttributes.Normal)                Dim o As IO.StreamWriter                If File.Exists(hostsfile) Then                    File.SetAttributes(hostsfile, FileAttributes.Normal)                    File.Delete(hostsfile)                    o = IO.File.AppendText(hostsfile)                    o.WriteLine("## L2J Hosts Manager - " & website & " ##")                    o.WriteLine("127.0.0.1      localhost")                    o.WriteLine(HostToIP(TextBox3.Text) & "      L2authd.lineage2.com")                    o.WriteLine("216.107.250.194      nprotect.lineage2.com")                    o.WriteLine("216.107.250.194      update.nProtect.com")                    o.Close()                Else                    File.SetAttributes(hostsfile, FileAttributes.Normal)                    o = IO.File.AppendText(hostsfile)                    o.WriteLine("## L2J Hosts Manager - " & website & " ##")                    o.WriteLine("127.0.0.1      localhost")                    o.WriteLine(HostToIP(TextBox3.Text) & " L2authd.lineage2.com")                    o.WriteLine("216.107.250.194 nprotect.lineage2.com")                    o.WriteLine("216.107.250.194 update.nProtect.com")                    o.Close()                End If                Log("Hosts have been updated to {" & TextBox3.Text & "} with {" & HostToIP(TextBox3.Text) & "} [" & DateTime.Now & "]")            End If        Else            Timer1.Stop()            Log("Autoupdate is disabled!")        End If    End Sub     Function HostToIP(ByVal host As String)        Dim hostname As IPHostEntry = Dns.GetHostByName(host)        Dim ip As IPAddress() = hostname.AddressList        Return ip(0).ToString()    End Function     Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem.Click        TextBox1.Copy()    End Sub     Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click        MsgBox("-- Log System v1.0.1 --" & vbNewLine & "Coded by Stealth.")    End Sub     Private Sub ClearToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearToolStripMenuItem.Click        If TextBox1.Text.Length > 0 Then            Dim j As String = MsgBox("Are you sure you wish to clear the textbox?", MsgBoxStyle.YesNo)            If j = MsgBoxResult.Yes Then                TextBox1.Clear()            ElseIf j = MsgBoxResult.No Then                'Do nothin' here.            End If        End If    End Sub     Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click        Dim s As SaveFileDialog = New SaveFileDialog        s.Filter = "Plain text (*.txt)|*.txt"        If s.ShowDialog = Windows.Forms.DialogResult.OK Then            Dim i As StreamWriter            i = IO.File.AppendText(s.FileName)            i.WriteLine(TextBox1.Text)            i.Close()        Else        End If    End Sub     Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click        Process.Start(website)    End Sub     Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click        If hostsfile.ToString.Length > 0 Then            File.SetAttributes(hostsfile, FileAttributes.ReadOnly)            Log("Hosts file {" & hostsfile & "} has been set to read-only.")        End If    End SubEnd Class 
User avatar
denser
Posts: 1392
Joined: Wed May 30, 2007 9:13 pm
Location: Russia
Contact:

Re: L2 Hosts Manager v1.6

Post by denser »

may be instead of C:\windows\system32\drivers\etc\hosts use %systemfolder%\drivers..... - so no need to manual finding?
Tiger, once tasted human flesh, will want to taste it again
L2J - the place where glad to see you any time!
User avatar
MEC
Posts: 18
Joined: Thu Apr 01, 2010 12:50 am
Location: ND
Contact:

Re: L2 Hosts Manager v1.6

Post by MEC »

that is the best program i've seen yet. i could see many uses for that outside of server hosting.

very nice. good job!
Image
Xaras2
Posts: 55
Joined: Sun May 13, 2007 4:47 am
Location: Italia
Contact:

Re: L2 Hosts Manager v1.6

Post by Xaras2 »

one program that i can use in a private server with a dinamic ip exist?
a program that, when changing ip, change the file "server.properties" and "loginserver.properties" and restart the "login server" and the "game server"
THX
Post Reply