sshd

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package sshd implements the inbound (server-side) half of the bastion: listener, handshake, authentication and channel dispatch.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Route

type Route struct {
	User   string
	Target string
}

Route is the parsed form of the "user:target" SSH username convention.

func ParseUsername

func ParseUsername(raw string) (Route, error)

ParseUsername splits raw ("user:target") into a Route.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server accepts inbound SSH connections on behalf of the bastion.

func New

func New(cfg *config.Config, db *store.Store, logger *slog.Logger) (*Server, error)

New prepares the server.

func (*Server) EnableOOB

func (s *Server) EnableOOB(logins *auth.Logins, timeout time.Duration)

EnableOOB, tarayıcı destekli girişi açar. serve, config'te oidc+http varsa çağırır; testler ve OIDC'siz kurulumlar hiç çağırmaz. timeout 0 ise varsayılan (oobTimeout) kullanılır — testler kısaltabilir.

Dinlemeye başlamadan ÖNCE çağrılmalı: alanlar kilitsiz, eşzamanlı handshake'lerle yarışmamalı.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(ctx context.Context) error

ListenAndServe listens on cfg.Listen.Addr and hands the listener to Serve.

func (*Server) LiveSessions

func (s *Server) LiveSessions() *proxy.Live

* LiveSessions, akan oturum defterini döner. * * ⚠️ PANELE AYRI VERİLİYOR, ProxyDeps üzerinden DEĞİL. httpapi'nin * proxyDeps alanı yalnızca http.terminal_enabled açıkken doluyor * (serve.go). Defteri oraya asmak, kesme düğmesini varsayılan * kurulumda — terminal kapalı, yalnızca SSH — sessizce yok ederdi: * bu depodaki tekrar eden arıza sınıfının ("yazıldı, bağlanmadı") tam * olarak kendisi. O yüzden ayrı bir kapı.

func (*Server) ProxyDeps

func (s *Server) ProxyDeps() proxy.Deps

func (*Server) Records

func (s *Server) Records() *record.Store

Records, kayıt deposunu döner.

httpapi ile PAYLAŞILIR: panel kayıtları AYNI depodan okumalı, yoksa "hangi dizin" sorusunun iki cevabı olur.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, l net.Listener) error

* Serve accepts connections from l until ctx is cancelled, then drains. * * ⚠️ KAPANIŞTA BEKLİYOR — VE BEKLEMİYORDU. ctx iptal edilince * dinleyici kapanıyor, döngü `return nil` diyordu ve bağlantıları * taşıyan goroutine'leri bekleyen HİÇBİR ŞEY yoktu: süreç ölürken o an * bağlı olan herkesin oturumu ortasından kopuyordu. Bedeli yalnızca * kullanıcının rahatsızlığı değildi — Session.Close hiç çalışmadığı * için kayıt yarım kapanıyor ve arşiv kuyruğuna hiç girmiyordu, yani * bir yeniden başlatma o oturumların kaydını hem eksik hem * yüklenemez bırakıyordu. * * Sıra: dinlemeyi bırak → açık oturumları drain süresince bekle → * kalanları SEBEBİYLE kapat → onların da bitmesini bekle.

func (*Server) UseEventBus

func (s *Server) UseEventBus(p events.Publisher)

UseEventBus, canlı izleme akışını bağlar. Çağrılmazsa olay yayınlanmaz.

func (*Server) UseGroupSource

func (s *Server) UseGroupSource(src auth.GroupSource)

UseGroupSource, grup kaynağını değiştirir (LDAP için). Dinlemeye başlamadan ÖNCE çağrılmalı.

func (*Server) UseRoleRefresher

func (s *Server) UseRoleRefresher(fn func(context.Context, string) error)

ProxyDeps, oturum akışının ihtiyaç duyduğu altyapıyı döner.

httpapi ile PAYLAŞILIR: web terminali ve SSH aynı store'u, aynı kayıt dizinini ve aynı CA'yı kullanmalı — iki kapı, tek gerçek. UseRoleRefresher, oturum açılışında yetkiyi tazeleyen fonksiyonu bildirir. Dinlemeye başlamadan ÖNCE çağrılmalı: alan kilitsiz.

Aynı fonksiyon web terminaline de gidiyor (ProxyDeps paylaşılıyor) — iki kapı tek kuralı uyguluyor.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL