Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

Snif / Snip / Snic remoting framework

Snif is StreamSec's class-remoting framework: a secure, DataSnap / RemObjects-style application server in which a plain Delphi class on the server is called remotely from a client through a typed interface proxy. Calls are dispatched by RTTI — there are no skeletons to hand-write — and the call/response is marshalled over a pluggable octet transport (an in-memory pipe, TLS, or an SSH-tunnelled channel).

The three layers

LayerUnitsRole
SnifStreamSec.Snif.*the server / application side
SnicStreamSec.Snic.*the client side
SnipStreamSec.Snip.*the transport (IsnipConnection)

Snif — the server side

Snic — the client side

TsnicClassClient.MakeInstance(QualifiedClassName, TypeInfo(IFoo), Obj, Role) returns a TVirtualInterface proxy. Calling a method on the proxy marshals a request over the connection and returns the result.

Snip — the transport

Authentication

Over SSH, authentication is two-layered: (1) the SSH transport user, and (2) the Snif application user via the Login exchange. The in-memory transport has only the Snif layer. The Snif password login is an augmented (asymmetric) PAKE built on a KEM (it replaced the library's earlier bespoke verifier-based challenge-response scheme): the server stores only a per-user verifier, never the password — see the Tunnel Bound KAPA notes. Records are persisted by the TsnifUserFileStorage component, and the session is bound to the authentication through StreamSec.Snif.ChannelBinding.

Writing your own remoted service — the pattern

Declare the interface and the server class in a shared unit (compiled into both ends so the proxy type matches):

{$M+}
IMyService = interface
['{...GUID...}']
  function DoThing(const A: string): Integer;
end;
{$M-}

{$TYPEINFO ON}{$METHODINFO ON}
[InstanceKind(perSession),Roles('myrole')]   // a class with NEITHER Roles NOR Anonymous is DENIED
TMyService = class
public
  [Roles('myrole')]
  function DoThing(const A: string): Integer;
end;
{$METHODINFO OFF}

Server startup:

Server.RegisterServerClass(TMyService);   // before accepting connections
// provision SSH users (Server.SSHUsers) and Snif users (UpdateUserList)
Server.Start;

Client:

Client.MakeInstance('MyUnit.TMyService', TypeInfo(IMyService), Svc, '');
n := Svc.DoThing('hello');

Gotchas worth knowing

The demos

Runnable demos live in Demos\Delphi 13\Snif\; the shared mock "business" classes and client interfaces are used identically across transports.

Core

Callback\ — publish/subscribe over server→client callbacks

A client passes an IChatListener to TChatRoom.Subscribe; the framework wraps it as a server-held proxy bound to that connection, and TChatRoom.Publish calls OnMessage back on every subscriber — the inverse of a normal RPC, needing a background pump thread on each client. Demos: CallbackProof (in-memory), CallbackServer + CallbackSshProof (SSH), and ChatClient (VCL; run two instances).

Mediator\ — peer-to-peer "colleague" access

One "owner" connection creates an instance; other "colleague" connections reach that same instance via SubscribeMediator. Acceptance depends on the class MediatorKind and Roles: viaSession (same session), viaUser (same user, any session), viaRole (share a class role — ownership needs ALL roles, subscription needs ANY one), viaApplication (any authenticated colleague). Demos: MediatorProof (in-memory accept/deny matrix), MediatorServer + MediatorSshProof (SSH), and MediatorOwner / MediatorColleague (VCL).

Building: RAD Studio 13 (BDS 37.0); demo .dproj search paths point at ..\..\..\Source. For a full application built on this framework (the PersonalAdmin self-service class over snip-over-SSH), see the SSH Tunnel Server / Client demos in ..\SSH\.