This commit is contained in:
Clemens Vasters 2018-07-08 21:44:02 +02:00
Родитель 278a5117eb
Коммит 8796403dc3
8 изменённых файлов: 147 добавлений и 67 удалений

Просмотреть файл

@ -1,2 +1,2 @@
@ECHO OFF
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' default-build %*; exit $LASTEXITCODE"
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' %*; exit $LASTEXITCODE"

Просмотреть файл

@ -5,4 +5,4 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Call "sync" between "chmod" and execution to prevent "text file busy" error in Docker (aufs)
chmod +x "$DIR/run.sh"; sync
"$DIR/run.sh" default-build "$@"
"$DIR/run.sh" "$@"

Просмотреть файл

@ -31,7 +31,7 @@
<SystemDiagnosticsDiagnosticSourcePackageVersion>4.5.0</SystemDiagnosticsDiagnosticSourcePackageVersion>
<SystemNetHttpPackageVersion>4.3.1</SystemNetHttpPackageVersion>
<SystemNetNameResolutionPackageVersion>4.3.0</SystemNetNameResolutionPackageVersion>
<YamlDotNetSignedPackageVersion>4.3.1</YamlDotNetSignedPackageVersion>
<YamlDotNetSignedPackageVersion>5.0.0</YamlDotNetSignedPackageVersion>
<MicrosoftExtensionsLoggingPackageVersion>2.1.0</MicrosoftExtensionsLoggingPackageVersion>
<MicrosoftExtensionsLoggingConsolePackageVersion>2.1.0</MicrosoftExtensionsLoggingConsolePackageVersion>
<XunitPackageVersion>2.3.1</XunitPackageVersion>

2
run.sh
Просмотреть файл

@ -4,4 +4,4 @@ set -euo pipefail
dotnet restore
dotnet test $@
dotnet build -c Release $@
dotnet msbuild $@

Просмотреть файл

@ -17,12 +17,15 @@ namespace Microsoft.Azure.Relay.Bridge.Configuration
private const string AzureBridgeName = "azbridge";
RelayConnectionStringBuilder relayConnectionStringBuilder;
readonly List<FileSystemWatcher> fileSystemWatchers;
List<LocalForward> localForward;
List<RemoteForward> remoteForward;
public Config()
{
relayConnectionStringBuilder = new RelayConnectionStringBuilder();
fileSystemWatchers = new List<FileSystemWatcher>();
localForward = new List<LocalForward>();
remoteForward = new List<RemoteForward>();
}
/// <summary>
@ -50,7 +53,20 @@ namespace Microsoft.Azure.Relay.Bridge.Configuration
/// <summary>
/// Azure Relay endpoint URI for a Relay namespace.
/// </summary>
public string AzureRelayEndpoint { get => RelayConnectionStringBuilder.Endpoint?.ToString(); set => RelayConnectionStringBuilder.Endpoint = (value != null)?new Uri(value):null; }
public string AzureRelayEndpoint {
get => RelayConnectionStringBuilder.Endpoint?.ToString();
set
{
if ( value == null )
{
RelayConnectionStringBuilder.Endpoint = new Uri("sb://undefined");
}
else
{
RelayConnectionStringBuilder.Endpoint = new Uri(value);
}
}
}
/// <summary>
/// Azure Relay shared access policy name.
@ -141,7 +157,21 @@ namespace Microsoft.Azure.Relay.Bridge.Configuration
/// Specifies that a (set of) TCP ports on the local machine
/// shall be forwarded via the Azure Relay.
/// </summary>
public List<LocalForward> LocalForward { get; set; } = new List<LocalForward>();
public List<LocalForward> LocalForward
{
get
{
return localForward;
}
set
{
localForward.Clear();
if ( value != null )
{
localForward.AddRange(value);
}
}
}
/// <summary>
/// Gives the verbosity level that is used when logging messages
@ -155,7 +185,21 @@ namespace Microsoft.Azure.Relay.Bridge.Configuration
/// Specifies that a TCP port on the remote machine be bound to
/// a name on the Azure Relay.
/// </summary>
public List<RemoteForward> RemoteForward { get; set; } = new List<RemoteForward>();
public List<RemoteForward> RemoteForward
{
get
{
return remoteForward;
}
set
{
remoteForward.Clear();
if ( value != null )
{
remoteForward.AddRange(value);
}
}
}
internal event EventHandler<ConfigChangedEventArgs> Changed;
void RaiseChanged(Config newConfig)
@ -481,8 +525,8 @@ namespace Microsoft.Azure.Relay.Bridge.Configuration
this.RemoteForward.Clear();
}
this.LocalForward.AddRange(otherConfig.LocalForward);
this.RemoteForward.AddRange(otherConfig.RemoteForward);
this.LocalForward?.AddRange(otherConfig.LocalForward);
this.RemoteForward?.AddRange(otherConfig.RemoteForward);
}
public static Config LoadConfigFile(string fileName)
@ -497,7 +541,15 @@ namespace Microsoft.Azure.Relay.Bridge.Configuration
using (var reader = new StreamReader(fileName))
{
return yamlDeserializer.Deserialize<Config>(reader);
try
{
return yamlDeserializer.Deserialize<Config>(reader);
}
catch(Exception e)
{
Console.WriteLine($"ser: {e.Message} {e.StackTrace} {e.InnerException?.Message} {e.InnerException?.StackTrace}");
throw;
}
}
}
else
@ -509,7 +561,8 @@ namespace Microsoft.Azure.Relay.Bridge.Configuration
static Deserializer yamlDeserializer =
new DeserializerBuilder()
.IgnoreUnmatchedProperties()
.WithNamingConvention(new PascalCaseNamingConvention()).Build();
.WithNamingConvention(new PascalCaseNamingConvention())
.Build();
static Serializer yamlSerializer =
new SerializerBuilder()

Просмотреть файл

@ -17,7 +17,7 @@
</ItemGroup> -->
<ItemGroup>
<LinuxFolder Include="/etc/azbridge" Group="azbridge" Owner="azbridge" RemoveOnUninstall="true" />
<!-- <LinuxFolder Include="/etc/azbridge" Group="azbridge" Owner="azbridge" RemoveOnUninstall="true" /> -->
<Content Include="azbridge_config.svc.yml" CopyToOutputDirectory="PreserveNewest">
<LinuxPath>/etc/azbridge/azbridge_config.yml</LinuxPath>
</Content>
@ -107,19 +107,36 @@
</ItemGroup>
<ItemGroup Condition="$(RuntimeIdentifier.StartsWith('debian')) OR $(RuntimeIdentifier.StartsWith('ubuntu')) OR $(RuntimeIdentifier.StartsWith('linuxmint'))">
<!-- <RpmDependency Include="lttng-ust" Version=""/> -->
<RpmDependency Include="libcurl3" Version=""/>
<RpmDependency Include="libssl1.0.0" Version=""/>
<RpmDependency Include="libkrb5-3" Version=""/>
<RpmDependency Include="zlib1g" Version=""/>
<RpmDependency Include="libicu52" Version="" Condition="'$(RuntimeIdentifier)'=='debian.8' OR '$(RuntimeIdentifier)'=='ubuntu.14'" />
<RpmDependency Include="libicu55" Version="" Condition="'$(RuntimeIdentifier)'=='ubuntu.16'" />
<RpmDependency Include="libicu57" Version="" Condition="'$(RuntimeIdentifier)'=='debian.9' OR '$(RuntimeIdentifier)'=='ubuntu.17' OR '$(RuntimeIdentifier)'=='linuxmint.17'" />
<RpmDependency Include="libicu60" Version="" Condition="'$(RuntimeIdentifier)'=='debian.10' OR '$(RuntimeIdentifier)'=='ubuntu.18' OR '$(RuntimeIdentifier)'=='linuxmint.18'" />
<RpmDependency Include="libunwind8" Version="" Condition="'$(TargetFramework)'=='netcoreapp2.0'"/>
<RpmDependency Include="libuuid1" Version="" Condition="'$(TargetFramework)'=='netcoreapp2.0'"/>
<!-- <DebDependency Include="lttng-ust" Version=""/> -->
<DebDependency Include="libcurl3" Version=""/>
<DebDependency Include="libssl1.0.0" Version=""/>
<DebDependency Include="libkrb5-3" Version=""/>
<DebDependency Include="zlib1g" Version=""/>
<DebDependency Include="libicu52" Version="" Condition="'$(RuntimeIdentifier)'=='debian.8' OR '$(RuntimeIdentifier)'=='ubuntu.14'" />
<DebDependency Include="libicu55" Version="" Condition="'$(RuntimeIdentifier)'=='ubuntu.16'" />
<DebDependency Include="libicu57" Version="" Condition="'$(RuntimeIdentifier)'=='debian.9' OR '$(RuntimeIdentifier)'=='ubuntu.17' OR '$(RuntimeIdentifier)'=='linuxmint.17'" />
<DebDependency Include="libicu60" Version="" Condition="'$(RuntimeIdentifier)'=='debian.10' OR '$(RuntimeIdentifier)'=='ubuntu.18' OR '$(RuntimeIdentifier)'=='linuxmint.18'" />
<DebDependency Include="libunwind8" Version="" Condition="'$(TargetFramework)'=='netcoreapp2.0'"/>
<DebDependency Include="libuuid1" Version="" Condition="'$(TargetFramework)'=='netcoreapp2.0'"/>
</ItemGroup>
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith('debian')) OR $(RuntimeIdentifier.StartsWith('ubuntu')) OR $(RuntimeIdentifier.StartsWith('linuxmint'))">
<PostInstallScript>
sudo /bin/echo #!/bin/sh > /etc/profile.d/azbridge.sh;
sudo /bin/echo export PATH="\$PATH:/usr/share/azbridge" >> /etc/profile.d/azbridge.sh;
sudo chmod a+x /etc/profile.d/azbridge.sh;
if [ ! -d "/etc/azbridge" ]; then sudo mkdir /etc/azbridge; fi
if [ ! -a "/etc/azbridge/azbridge_config.machine.yml" ]; then
sudo mv /usr/share/azbridge/azbridge_config.machine.yml /etc/azbridge/azbridge_config.machine.yml;
fi;
/etc/profile.d/azbridge.sh;
</PostInstallScript>
<PostRemoveScript>
if [ -f /etc/profile.d/azbridge.sh ]; then sudo /bin/rm /etc/profile.d/azbridge.sh; fi
</PostRemoveScript>
</PropertyGroup>
<!-- Linux Daemon install properties -->
<PropertyGroup Condition="$(UnixRuntimeIdentifiers.Contains($(RuntimeIdentifier)))">
<CreateUser>false</CreateUser>
@ -159,7 +176,7 @@
<Copy SourceFiles="$(DebPath)" DestinationFolder="$(BuildDir)/$(TargetFramework)"/>
</Target>
<Target Name="PackageRpm" DependsOnTargets="CreateRpm" Condition="'$(OS)' == 'Unix' AND ('$(TargetFramework)' == 'netcoreapp2.0' OR '$(TargetFramework)' == 'netcoreapp2.1') AND ($(RuntimeIdentifier.StartsWith('rhel')) OR $(RuntimeIdentifier.StartsWith('centos')) OR $(RuntimeIdentifier.StartsWith('fedora')) OR $(RuntimeIdentifier.StartsWith('opensuse')) OR $(RuntimeIdentifier.StartsWith('ol')))">
<Copy SourceFiles="$(RpmPath)" DestinationFolder="$(BuildDir)/$(TargetFramework)"/>
<Copy SourceFiles="$(RpmPath)" DestinationFolder="$(BuildDir)/$(TargetFramework)"/>
</Target>
<Target Name="PackageWindows" DependsOnTargets="Publish" Condition="'$(OS)' == 'Windows_NT' AND '$(TargetFramework)' == 'net462' AND $(RuntimeIdentifier.StartsWith('win')) AND $(RuntimeIdentifier.EndsWith($(PlatformTarget)))">
<PropertyGroup>

Просмотреть файл

@ -4,39 +4,39 @@
# arguments are "any", "inet" (use IPv4 only), or "inet6"
# (use IPv6 only). The default is "any".
AddressFamily:
AddressFamily :
# Azure Relay connection string for a Relay namespace. Only one
# namespace connection string can be specified per configuration
# file.
AzureRelayConnectionString:
AzureRelayConnectionString :
# Azure Relay endpoint URI for a Relay namespace. Overrides
# the 'Endpoint' property of the connection string, if present.
AzureRelayEndpoint:
AzureRelayEndpoint :
# Azure Relay shared access policy name. Overrides the 'SharedAccessKeyName'
# property of the connection string, if present.
AzureRelaySharedAccessKeyName:
AzureRelaySharedAccessKeyName :
# Azure Relay shared access policy key. Overrides the 'SharedAccessKey'
# property of the connection string, if present.
AzureRelaySharedAccessKey:
AzureRelaySharedAccessKey :
# Azure Relay shared access policy signature. Overrides the 'SharedAccessSignature'
# property of the connection string, if present.
AzureRelaySharedAccessSignature:
AzureRelaySharedAccessSignature :
# Use the specified address on the local machine as the source
# address of the connection. Only useful on systems with more than
# one address.
BindAddress:
BindAddress :
# Specifies that all local, and remote port forwardings
# specified in the configuration files or on the command line be
@ -44,38 +44,38 @@ BindAddress:
# command line to clear port forwardings set in configura-
# tion files. The argument must be "true" or "false". The default is "false".
ClearAllForwardings:
ClearAllForwardings :
# Specifies whether to use compression. The argument must be
# "true" or "false". The default is "false".
Compression:
Compression :
# Specifies the compression level to use if compression
# is enabled. The argument must be an integer from 1 (fast) to 9 (slow, best).
# The default level is 6, which is good for most applications.
CompressionLevel:
CompressionLevel :
# Specifies the number of tries (one per second) to make
# before exiting. The argument must be an integer. This may be useful in scripts
# if the connection sometimes fails. The default is 1.
ConnectionAttempts:
ConnectionAttempts :
# Specifies the timeout (in seconds) used when connecting to the
# relay server, instead of using the default system TCP timeout.
# This value is used only when the target is down or really
# unreachable, not when it refuses the connection.
ConnectTimeout:
ConnectTimeout :
# Specifies whether azbridge(1) should terminate the
# connection if it cannot set up all requested local, and remote port forwardings,
# (e.g. if either end is unable to bind and listen on a specified port).
# The argument must be "true" or "false". The default is "false".
ExitOnForwardFailure:
ExitOnForwardFailure :
# Specifies whether remote hosts are allowed to connect to local
# forwarded ports. By default, azbridge(1) binds local port forwardings
@ -85,25 +85,30 @@ ExitOnForwardFailure:
# hosts to connect to forwarded ports. The argument must be "true" or "false".
# The default is "false".
GatewayPorts:
GatewayPorts :
# Specifies that a (set of) TCP ports on the local machine
# shall be forwarded via the Azure Relay. Each entry can have four properties,
# "BindAddress", "Port", "LocalSocket", and "RelayName". See [below](#localforward-properties) for
# details.
# "BindAddress", "Port", "LocalSocket", and "RelayName".
LocalForward:
LocalForward :
# - BindAddress: 127.0.8.1
# Port: 443
# RelayName: a1
# Gives the verbosity level that is used when logging messages
# from azbridge(1). The possible values are: QUIET, FATAL, ERROR, INFO, VERBOSE,
# from azbridge(1). The possible values are : QUIET, FATAL, ERROR, INFO, VERBOSE,
# DEBUG, DEBUG1, DEBUG2, and DEBUG3. The default is INFO.
# DEBUG and DEBUG1 are equivalent. DEBUG2 and DEBUG3 each specify
# higher levels of verbose output.
LogLevel: ERROR
LogLevel : ERROR
# Specifies that a TCP port on the remote machine be bound to
# a name on the Azure Relay. Each entry can have four properties, "RelayName", "Host",
# "HostPort", and "LocalSocket". See [below](#remoteforward-properties) for details.
# "HostPort", and "LocalSocket".
RemoteForward:
RemoteForward :
# - RelayName: a1
# Host: localhost
# HostPort: 443

Просмотреть файл

@ -4,39 +4,39 @@
# arguments are "any", "inet" (use IPv4 only), or "inet6"
# (use IPv6 only). The default is "any".
AddressFamily:
AddressFamily :
# Azure Relay connection string for a Relay namespace. Only one
# namespace connection string can be specified per configuration
# file.
AzureRelayConnectionString:
AzureRelayConnectionString :
# Azure Relay endpoint URI for a Relay namespace. Overrides
# the 'Endpoint' property of the connection string, if present.
AzureRelayEndpoint:
AzureRelayEndpoint :
# Azure Relay shared access policy name. Overrides the 'SharedAccessKeyName'
# property of the connection string, if present.
AzureRelaySharedAccessKeyName:
AzureRelaySharedAccessKeyName :
# Azure Relay shared access policy key. Overrides the 'SharedAccessKey'
# property of the connection string, if present.
AzureRelaySharedAccessKey:
AzureRelaySharedAccessKey :
# Azure Relay shared access policy signature. Overrides the 'SharedAccessSignature'
# property of the connection string, if present.
AzureRelaySharedAccessSignature:
AzureRelaySharedAccessSignature :
# Use the specified address on the local machine as the source
# address of the connection. Only useful on systems with more than
# one address.
BindAddress:
BindAddress :
# Specifies that all local, and remote port forwardings
# specified in the configuration files or on the command line be
@ -44,38 +44,38 @@ BindAddress:
# command line to clear port forwardings set in configura-
# tion files. The argument must be "true" or "false". The default is "false".
ClearAllForwardings:
ClearAllForwardings :
# Specifies whether to use compression. The argument must be
# "true" or "false". The default is "false".
Compression:
Compression :
# Specifies the compression level to use if compression
# is enabled. The argument must be an integer from 1 (fast) to 9 (slow, best).
# The default level is 6, which is good for most applications.
CompressionLevel:
CompressionLevel :
# Specifies the number of tries (one per second) to make
# before exiting. The argument must be an integer. This may be useful in scripts
# if the connection sometimes fails. The default is 1.
ConnectionAttempts:
ConnectionAttempts :
# Specifies the timeout (in seconds) used when connecting to the
# relay server, instead of using the default system TCP timeout.
# This value is used only when the target is down or really
# unreachable, not when it refuses the connection.
ConnectTimeout:
ConnectTimeout :
# Specifies whether azbridge(1) should terminate the
# connection if it cannot set up all requested local, and remote port forwardings,
# (e.g. if either end is unable to bind and listen on a specified port).
# The argument must be "true" or "false". The default is "false".
ExitOnForwardFailure:
ExitOnForwardFailure :
# Specifies whether remote hosts are allowed to connect to local
# forwarded ports. By default, azbridge(1) binds local port forwardings
@ -85,25 +85,30 @@ ExitOnForwardFailure:
# hosts to connect to forwarded ports. The argument must be "true" or "false".
# The default is "false".
GatewayPorts:
GatewayPorts :
# Specifies that a (set of) TCP ports on the local machine
# shall be forwarded via the Azure Relay. Each entry can have four properties,
# "BindAddress", "Port", "LocalSocket", and "RelayName". See [below](#localforward-properties) for
# details.
# "BindAddress", "Port", "LocalSocket", and "RelayName".
LocalForward:
LocalForward :
# - BindAddress: 127.0.8.1
# Port: 443
# RelayName: a1
# Gives the verbosity level that is used when logging messages
# from azbridge(1). The possible values are: QUIET, FATAL, ERROR, INFO, VERBOSE,
# from azbridge(1). The possible values are : QUIET, FATAL, ERROR, INFO, VERBOSE,
# DEBUG, DEBUG1, DEBUG2, and DEBUG3. The default is INFO.
# DEBUG and DEBUG1 are equivalent. DEBUG2 and DEBUG3 each specify
# higher levels of verbose output.
LogLevel: ERROR
LogLevel : ERROR
# Specifies that a TCP port on the remote machine be bound to
# a name on the Azure Relay. Each entry can have four properties, "RelayName", "Host",
# "HostPort", and "LocalSocket". See [below](#remoteforward-properties) for details.
# "HostPort", and "LocalSocket".
RemoteForward:
RemoteForward :
# - RelayName: a1
# Host: localhost
# HostPort: 443