events

package
v1.0.2 Latest Latest
Warning

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

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

Documentation

Overview

Package events, bastion içinde olup biteni canlı izlemek isteyen abonelere dağıtır.

KAPSAM: yalnızca BU süreçte olan olaylar. CLI'dan yapılan yönetim işlemleri başka bir süreçte çalışıyor ve buradan geçmiyor — onların yeri admin_log tablosu. Panel ikisini birden gösteriyor ve hangisinin nereden geldiğini söylüyor; "canlı akış her şeyi gösteriyor" sanmak, göstermediğini fark etmemek demek olurdu.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

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

Bus, abonelere dağıtan veriyolu.

func New

func New(maxSubs, buffer int) *Bus

New, veriyolunu kurar. Sıfır/negatif değerler makul varsayılana düşer.

func (*Bus) Publish

func (b *Bus) Publish(e Event)

Publish, olayı bütün abonelere dağıtır.

⚠️ ASLA BLOKLAMAZ. Çağıranlar bir SSH oturumunun açılış/kapanış yolunda: burada beklemek, tarayıcısını açık unutmuş bir yöneticinin yavaş bağlantısının bir SSH oturumunu kilitlemesi demek olurdu. İzleme aracı, izlediği şeyi durduramaz. Tamponu dolmuş aboneye olay DÜŞÜRÜLÜR ve sayaç artar; abone bunu panelde görür.

func (*Bus) Stats

func (b *Bus) Stats() Stats

func (*Bus) Subscribe

func (b *Bus) Subscribe() (ch <-chan Event, cancel func(), ok bool)

Subscribe, yeni bir abone açar. İkinci dönen değer aboneliği kapatır ve birden çok kez çağrılabilir.

Kapasite dolmuşsa ok=false döner: sessizce boş bir kanal vermek, panelin "bağlıyım ama hiç olay gelmiyor" demesine yol açardı.

type Event

type Event struct {
	At     time.Time `json:"at"`
	Kind   Kind      `json:"kind"`
	User   string    `json:"user,omitempty"`
	Target string    `json:"target,omitempty"`
	Source string    `json:"source,omitempty"` // istemcinin adresi
	Detail string    `json:"detail,omitempty"`
}

Event, tek bir olay.

⚠️ İÇİNDE SIR YOK ve olmamalı: bu yapı doğrudan tarayıcıya JSON olarak akıyor. Sertifika, token, parola ya da doğrulama kodu buraya konursa panelde oturum açmış her yöneticinin ekranına düşer.

type Kind

type Kind string

Kind, olay türü. Panelde süzme ve simge seçimi buna bakıyor.

const (
	SessionStarted Kind = "session.started"
	SessionEnded   Kind = "session.ended"
	AuthDenied     Kind = "auth.denied"
	AuthOK         Kind = "auth.ok"
)

type Nop

type Nop struct{}

Nop, olay yayını kapalıyken kullanılan Publisher.

func (Nop) Publish

func (Nop) Publish(Event)

type Publisher

type Publisher interface {
	Publish(Event)
}

Publisher, üretici tarafın gördüğü yüz.

proxy ve sshd bu arayüzü alıyor, *Bus'ı değil: nil bir Publisher yerine no-op geçebilmek ve testte yayınları toplayabilmek için.

type Stats

type Stats struct {
	Subscribers int    `json:"subscribers"`
	Dropped     uint64 `json:"dropped"`
}

Stats, panelde gösterilen sayaçlar.

Jump to

Keyboard shortcuts

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