Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cljung committed Dec 17, 2015
1 parent 35f3cc0 commit 76b6250
Show file tree
Hide file tree
Showing 6 changed files with 333 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
44 changes: 44 additions & 0 deletions azftp2blob.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "azftp2blob", "azftp2blob\azftp2blob.csproj", "{4890529F-5A8F-46BF-B1B3-6BAD6602A106}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AzureFtpServer", "AzureFtpServer\AzureFtpServer.csproj", "{A6520CEB-6E55-4C9D-B581-64E432DB16D0}"
EndProject
Project("{F5034706-568F-408A-B7B3-4D38C6DB8A32}") = "DeploymentScripts", "DeploymentScripts\DeploymentScripts.pssproj", "{6CAFC0C6-A428-4D30-A9F9-700E829FEA51}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4890529F-5A8F-46BF-B1B3-6BAD6602A106}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4890529F-5A8F-46BF-B1B3-6BAD6602A106}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4890529F-5A8F-46BF-B1B3-6BAD6602A106}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4890529F-5A8F-46BF-B1B3-6BAD6602A106}.Release|Any CPU.Build.0 = Release|Any CPU
{A6520CEB-6E55-4C9D-B581-64E432DB16D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A6520CEB-6E55-4C9D-B581-64E432DB16D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A6520CEB-6E55-4C9D-B581-64E432DB16D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A6520CEB-6E55-4C9D-B581-64E432DB16D0}.Release|Any CPU.Build.0 = Release|Any CPU
{6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 1
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = https://redbaron.visualstudio.com/defaultcollection
SccProjectUniqueName0 = AzureFtpServer\\AzureFtpServer.csproj
SccProjectName0 = AzureFtpServer
SccAuxPath0 = https://redbaron.visualstudio.com/defaultcollection
SccLocalPath0 = AzureFtpServer
SccProvider0 = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
EndGlobalSection
EndGlobal
36 changes: 36 additions & 0 deletions azftp2blob/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
<appSettings>
<add key="FTP" value="21"/>
<!-- changed by installation script on the fly -->
<add key="FTPPASV" value="59860"/>
<!-- Azure Storage Account -->
<!-- changed by installation script on the fly -->
<add key="StorageAccount" value="DefaultEndpointsProtocol=https;AccountName=...;AccountKey=..."/>
<!-- Ftp server site, used to get its ipv4 ip, e.g. xxx.cloudapp.net-->
<add key="FtpServerHost" value="%computername%"/>
<!-- changed by installation script on the fly -->
<add key="FtpServerHostPublic" value="%computername%"/>
<!-- if to overwrite file by default in STOR command (uploads) RFC959 says you should -->
<add key="FtpOverwriteFileOnSTOR" value="True"/>
<!-- if to replace adjacent slashes in path to single, ie subdir1//subdir2//dubdir3 to subdir1/subdir2/dubdir3. NTFS sees them as same while Blob Storgae sees it as different -->
<add key="FtpReplaceSlashOnDELE" value="True"/>
<!-- changed by installation script on the fly -->
<add key="LogPath" value="C:\ftpdir\log"/>
<add key="LoggingEnabled" value="True"/>
<!-- Mode="Debug", use development storage; Mode="Live", use azure storage-->
<add key="Mode" value="Live"/>
<!-- Max number of concurrent clients -->
<add key="MaxClients" value="30"/>
<!-- Ftp Server Account Management - external text file -->
<add key="FtpAccount" value="userlist.txt"/>
<!-- No need to edit these unless specifically required (reserved for future use) -->
<add key="ConnectionEncoding" value="UTF8"/>
<add key="MaxIdleSeconds" value="60"/>
<add key="QueueNotification" value="true"/>

</appSettings>
</configuration>
79 changes: 79 additions & 0 deletions azftp2blob/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AzureFtpServer.Azure;
using AzureFtpServer.Ftp;
using AzureFtpServer.Provider;

// https://ftp2azure.codeplex.com/SourceControl/latest

namespace azftp2blob
{
class Program
{
private FtpServer _server;
private bool _verbose = true;

static void Main(string[] args)
{
Program p = new Program();
p.Go(args);
}
private int FindArg(string[] args, string argument)
{
if (argument.StartsWith("/") || argument.StartsWith("-"))
argument = argument.Substring(1);
for (int n = 0; n < args.Length; n++)
{
string arg = args[n];
if (arg.StartsWith("/") || arg.StartsWith("-"))
arg = arg.Substring(1);
if (string.Compare(arg, argument, true) == 0)
return n;
}
return -1;
}
private string GetArgument(string[] args, string key, string defaultValue)
{
// get key/value from A) App.Config, B) env var, C) command line
string value = ConfigurationManager.AppSettings[key];
string buf = Environment.GetEnvironmentVariable(key);
if (!string.IsNullOrWhiteSpace(buf))
value = buf;
int idx;
if (-1 != (idx = FindArg(args, key)))
{
value = args[idx + 1];
}
if (value == null)
value = defaultValue;
return value;
}
private bool GetArgsAndConfig(string[] args)
{
bool rc = false;
_verbose = GetArgument(args, "verbose", "false").ToLowerInvariant() == "true";
return rc;
}
public void Go(string[] args)
{
GetArgsAndConfig(args);
if (_verbose)
{
ConsoleTraceListener conTrace = new ConsoleTraceListener();
Trace.Listeners.Add(conTrace);
}
_server = new FtpServer(new AzureFileSystemFactory());
_server.NewConnection += ServerNewConnection;
_server.Start();
}
static void ServerNewConnection(int nId)
{
Console.WriteLine(String.Format("Connection {0} accepted", nId), "Connection");
}
}
}
36 changes: 36 additions & 0 deletions azftp2blob/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("azftp2blob")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("azftp2blob")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("4890529f-5a8f-46bf-b1b3-6bad6602a106")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
75 changes: 75 additions & 0 deletions azftp2blob/azftp2blob.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" 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>{4890529F-5A8F-46BF-B1B3-6BAD6602A106}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>azftp2blob</RootNamespace>
<AssemblyName>azftp2blob</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</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>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AzureFtpServer\AzureFtpServer.csproj">
<Project>{a6520ceb-6e55-4c9d-b581-64e432db16d0}</Project>
<Name>AzureFtpServer</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="userlist.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

0 comments on commit 76b6250

Please sign in to comment.