using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Security.Permissions;
using System.Runtime.Serialization.Formatters;
using System.Collections;
using r;
namespace WindowsApplication12
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
// Show the name and priority of the channel.
Console.WriteLine("Channel Name: {0}", serverChannel.ChannelName);
Console.WriteLine("Channel Priority: {0}", serverChannel.ChannelPriority);
// Show the URIs associated with the channel.
ChannelDataStore data = (ChannelDataStore)serverChannel.ChannelData;
foreach (string uri in data.ChannelUris)
{
Console.WriteLine(uri);
}
// Wait for method calls.
Console.WriteLine("Listening...");
using System;
using System.Collections;
using System.IO;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Channels;
using System.Threading;
using System.Net;
using System.Security.Principal;
namespace r
{
public class Remotable : MarshalByRefObject
{
private int callCount = 0;
public int GetCount()
{
callCount++;
return (callCount);
}
}
public class cmyLogin : IAuthorizeRemotingConnection
{
public bool IsConnectingEndPointAuthorized(EndPoint endPoint)
{
if (endPoint.AddressFamily.ToString() != "")
return true;
else
return true;
}
public bool IsConnectingIdentityAuthorized(IIdentity identity)
{
return true;
}
}
public class ClientIPServerSinkProvider : IServerChannelSinkProvider
{
private IServerChannelSinkProvider next = null;
public ClientIPServerSinkProvider()
{
}
public void GetChannelData(IChannelDataStore channelData)
{
}
public IServerChannelSink CreateSink(IChannelReceiver channel)
{
IServerChannelSink nextSink = null;
if (next != null)
{
nextSink = next.CreateSink(channel);
}
return new ClientIPServerSink(nextSink);
}
public IServerChannelSinkProvider Next
{
get { return next; }
set { next = value; }
}
}
public class ClientIPServerSink : BaseChannelObjectWithProperties, IServerChannelSink, IChannelSinkBase
{
private IServerChannelSink _next;
public ClientIPServerSink(IServerChannelSink next)
{
_next = next;
}
public System.Runtime.Remoting.Channels.ServerProcessing ProcessMessage(System.Runtime.Remoting.Channels.IServerChannelSinkStack sinkStack, System.Runtime.Remoting.Messaging.IMessage requestMsg, System.Runtime.Remoting.Channels.ITransportHeaders requestHeaders, System.IO.Stream requestStream, out System.Runtime.Remoting.Messaging.IMessage responseMsg, out System.Runtime.Remoting.Channels.ITransportHeaders responseHeaders, out System.IO.Stream responseStream)
{
if (_next != null)
{
IPAddress ip = requestHeaders[CommonTransportKeys.IPAddress] as IPAddress;
Console.WriteLine(ip.ToString());
CallContext.SetData("ClientIPAddress", ip);
ServerProcessing spres = _next.ProcessMessage(sinkStack, requestMsg, requestHeaders, requestStream, out responseMsg, out responseHeaders, out responseStream);
// Summary:
// Defines how well-known objects are activated.
[Serializable]
[ComVisible(true)]
public enum WellKnownObjectMode
{
// Summary:
// Every incoming message is serviced by the same object instance.
Singleton = 1,
//
// Summary:
// Every incoming message is serviced by a new object instance.
SingleCall = 2,
}