Skip to content

Commit

Permalink
First import
Browse files Browse the repository at this point in the history
  • Loading branch information
savissimo committed Feb 8, 2018
1 parent 71b081a commit 1432945
Show file tree
Hide file tree
Showing 28 changed files with 1,421 additions and 1 deletion.
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,26 @@
# routingtablemanager
# Routing Table Manager

A tool to quickly add entries to the Windows routing table. Host names are resolved with DNS for user convenience.

## Features

* Routing entries may specify a destination and a gateway either as an IP address or as a host name, which will be resolved with DNS
* Routing entries can point to a specific network interface
* Projects contain multiple routing entries, so you can group them and enable them at once
* Command-line parameter allows to apply all the entries of a project without opening the UI
* It needs a Windows account with elevated privileges

## Project status

The tool is now functional, at least as to what I need it for. It was meant as a quick and convenient way to add entries to the system routing table, and that it does.

**I don't plan to refine it any further**. I have no interest in new features or in a nicer UI, and I am caught in several other projects.

### "Then why did you put it here?!"

Because I'm a nice guy ;)

Just because I have no plans for this project, it doesn't mean _you_ have none! I decided to open this project for three main reasons:
1. so that people can use it, if they need to. They can't if it sits on my hard drive;
2. so that people can point out problems. What works for me may not work for you;
3. so that people can pick up from here and improve it themselves :)
6 changes: 6 additions & 0 deletions src/Desktop/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
8 changes: 8 additions & 0 deletions src/Desktop/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Application x:Class="Desktop.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Desktop" Startup="Application_Startup" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" d1p1:Ignorable="d" xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006">
<Application.Resources>
<ResourceDictionary>
<vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" xmlns:vm="clr-namespace:Desktop.ViewModel" />
<local:DebugConverter x:Key="DebugConverter" />
</ResourceDictionary>
</Application.Resources>
</Application>
35 changes: 35 additions & 0 deletions src/Desktop/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Desktop.ViewModels;
using Desktop.Views;
using RoutingTableManager;
using System.IO;
using System.Windows;

namespace Desktop
{
/// <summary>
/// Logica di interazione per App.xaml
/// </summary>
public partial class App : Application
{
private void Application_Startup(object sender, StartupEventArgs e)
{
if (e.Args.Length > 0)
{
if (File.Exists(e.Args[0]))
{
RoutingTable routingTable = new RoutingTable();
routingTable.LoadFromXml(e.Args[0]);
routingTable.ApplyToSystem();
MessageBox.Show("All routes applied.");
}

Application.Current.Shutdown();
}

MainViewModel mvm = new MainViewModel();
MainWindow mv = new MainWindow();
mvm.BindView(mv);
mv.Show();
}
}
}
39 changes: 39 additions & 0 deletions src/Desktop/Controls/PersistentOpenFileDialog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Microsoft.Win32;
using System.IO;

namespace Desktop.Controls
{
public class PersistentOpenFileDialog
{
OpenFileDialog m_ofd = new OpenFileDialog();
string m_persistentDirectory = null;

public PersistentOpenFileDialog()
{
m_ofd.CheckFileExists = true;
m_ofd.CheckPathExists = true;
m_ofd.ReadOnlyChecked = true;
}

public bool? ShowDialog()
{
if (m_persistentDirectory != null)
{
m_ofd.InitialDirectory = m_persistentDirectory;
}
bool? retval = m_ofd.ShowDialog();
if (retval == true)
{
m_persistentDirectory = new FileInfo(FileName).DirectoryName;
}

return retval;
}

public string FileName
{
get { return m_ofd.FileName; }
set { m_ofd.FileName = value; }
}
}
}
22 changes: 22 additions & 0 deletions src/Desktop/DebugConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Diagnostics;
using System.Globalization;
using System.Windows.Data;

namespace Desktop
{
class DebugConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Debugger.Break();
return value;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
Debugger.Break();
return value;
}
}
}
130 changes: 130 additions & 0 deletions src/Desktop/Desktop.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{15569582-A792-40B2-84EE-44184B93EAF2}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Desktop</RootNamespace>
<AssemblyName>RoutingTableManager</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="GalaSoft.MvvmLight, Version=5.3.0.19026, Culture=neutral, PublicKeyToken=e7570ab207bcb616, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight.Extras, Version=5.3.0.19032, Culture=neutral, PublicKeyToken=669f0b5e8f868abf, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Extras.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight.Platform, Version=5.3.0.19032, Culture=neutral, PublicKeyToken=5f873c45e98af8a1, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Practices.ServiceLocation, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.3.0.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="Views\MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Controls\PersistentOpenFileDialog.cs" />
<Compile Include="DebugConverter.cs" />
<Compile Include="ViewModels\MainViewModel.cs" />
<Compile Include="ViewModels\ViewModelBaseExtensions.cs" />
<Compile Include="ViewModel\ViewModelLocator.cs" />
<Compile Include="Views\MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="app.manifest">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RoutingTableManager\RoutingTableManager.csproj">
<Project>{A6436D0A-491C-4D6F-82FA-8222CE3CD93B}</Project>
<Name>RoutingTableManager</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
55 changes: 55 additions & 0 deletions src/Desktop/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;

// Le informazioni generali relative a un assembly sono controllate dal seguente
// set di attributi. Modificare i valori di questi attributi per modificare le informazioni
// associate a un assembly.
[assembly: AssemblyTitle("Routing Table Manager")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Routing Table Manager")]
[assembly: AssemblyCopyright("Copyright © Simone Saviolo 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili
// ai componenti COM. Se è necessario accedere a un tipo in questo assembly da
// COM, impostare su true l'attributo ComVisible per tale tipo.
[assembly: ComVisible(false)]

//Per iniziare a creare applicazioni localizzabili, impostare
//<UICulture>CultureYouAreCodingWith</UICulture> nel file .csproj
//all'interno di un <PropertyGroup>. Ad esempio, se si utilizza l'inglese (Stati Uniti)
//nei file di origine, impostare <UICulture> su en-US. Rimuovere quindi il commento dall'attributo
//NeutralResourceLanguage riportato di seguito. Aggiornare "en-US" nella
//riga sottostante in modo che corrisponda all'impostazione UICulture nel file di progetto.

//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]


[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //dove si trovano i dizionari delle risorse specifiche del tema
//(da usare se nella pagina non viene trovata una risorsa,
// oppure nei dizionari delle risorse dell'applicazione)
ResourceDictionaryLocation.SourceAssembly //dove si trova il dizionario delle risorse generiche
//(da usare se nella pagina non viene trovata una risorsa,
// nell'applicazione o nei dizionari delle risorse specifiche del tema)
)]


// Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori:
//
// Versione principale
// Versione secondaria
// Numero di build
// Revisione
//
// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
// usando l'asterisco '*' come illustrato di seguito:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading

0 comments on commit 1432945

Please sign in to comment.