forked from mleku/next.orly.dev
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
c7eb532443
|
|||
|
e56b3f0083
|
|||
|
|
9064b3ab5f |
8
.github/workflows/go.yml
vendored
8
.github/workflows/go.yml
vendored
@@ -76,10 +76,10 @@ jobs:
|
|||||||
|
|
||||||
# Build for different platforms
|
# Build for different platforms
|
||||||
GOEXPERIMENT=greenteagc,jsonv2 GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -o release-binaries/orly-${VERSION}-linux-amd64 .
|
GOEXPERIMENT=greenteagc,jsonv2 GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -o release-binaries/orly-${VERSION}-linux-amd64 .
|
||||||
GOEXPERIMENT=greenteagc,jsonv2 GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o release-binaries/orly-${VERSION}-linux-arm64 .
|
# GOEXPERIMENT=greenteagc,jsonv2 GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o release-binaries/orly-${VERSION}-linux-arm64 .
|
||||||
GOEXPERIMENT=greenteagc,jsonv2 GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -o release-binaries/orly-${VERSION}-darwin-amd64 .
|
# GOEXPERIMENT=greenteagc,jsonv2 GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -o release-binaries/orly-${VERSION}-darwin-amd64 .
|
||||||
GOEXPERIMENT=greenteagc,jsonv2 GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -o release-binaries/orly-${VERSION}-darwin-arm64 .
|
# GOEXPERIMENT=greenteagc,jsonv2 GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -o release-binaries/orly-${VERSION}-darwin-arm64 .
|
||||||
GOEXPERIMENT=greenteagc,jsonv2 GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -o release-binaries/orly-${VERSION}-windows-amd64.exe .
|
# GOEXPERIMENT=greenteagc,jsonv2 GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -o release-binaries/orly-${VERSION}-windows-amd64.exe .
|
||||||
|
|
||||||
# Note: Only building orly binary as requested
|
# Note: Only building orly binary as requested
|
||||||
# Other cmd utilities (aggregator, benchmark, convert, policytest, stresstest) are development tools
|
# Other cmd utilities (aggregator, benchmark, convert, policytest, stresstest) are development tools
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ func (l *Listener) HandleEvent(msg []byte) (err error) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
log.I.F("HandleEvent: continuing with event processing...")
|
|
||||||
if len(msg) > 0 {
|
if len(msg) > 0 {
|
||||||
log.I.F("extra '%s'", msg)
|
log.I.F("extra '%s'", msg)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -285,16 +284,18 @@ func (p *P) CheckPolicy(access string, ev *event.E, loggedInPubkey []byte, ipAdd
|
|||||||
// Check if script is present and enabled
|
// Check if script is present and enabled
|
||||||
if rule.Script != "" && p.Manager != nil {
|
if rule.Script != "" && p.Manager != nil {
|
||||||
if p.Manager.IsEnabled() {
|
if p.Manager.IsEnabled() {
|
||||||
return p.checkScriptPolicy(access, ev, rule.Script, loggedInPubkey, ipAddress)
|
// Check if script file exists before trying to use it
|
||||||
}
|
if _, err := os.Stat(p.Manager.GetScriptPath()); err == nil {
|
||||||
// Script is configured but policy is disabled - use default policy if rule has no other restrictions
|
// Script exists, try to use it
|
||||||
hasOtherRestrictions := len(rule.WriteAllow) > 0 || len(rule.WriteDeny) > 0 || len(rule.ReadAllow) > 0 || len(rule.ReadDeny) > 0 ||
|
allowed, err := p.checkScriptPolicy(access, ev, rule.Script, loggedInPubkey, ipAddress)
|
||||||
rule.SizeLimit != nil || rule.ContentLimit != nil || len(rule.MustHaveTags) > 0 ||
|
if err == nil {
|
||||||
rule.MaxExpiry != nil || rule.Privileged || rule.RateLimit != nil ||
|
// Script ran successfully, return its decision
|
||||||
rule.MaxAgeOfEvent != nil || rule.MaxAgeEventInFuture != nil
|
return allowed, nil
|
||||||
if !hasOtherRestrictions {
|
}
|
||||||
// No other restrictions, use default policy
|
// Script failed, fall through to apply other criteria
|
||||||
return p.getDefaultPolicyAction(), nil
|
log.W.F("policy script check failed for kind %d: %v, applying other criteria", ev.Kind, err)
|
||||||
|
}
|
||||||
|
// Script doesn't exist or failed, fall through to apply other criteria
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -481,24 +482,14 @@ func (p *P) checkScriptPolicy(access string, ev *event.E, scriptPath string, log
|
|||||||
if !p.Manager.IsRunning() {
|
if !p.Manager.IsRunning() {
|
||||||
// Check if script file exists
|
// Check if script file exists
|
||||||
if _, err := os.Stat(p.Manager.GetScriptPath()); os.IsNotExist(err) {
|
if _, err := os.Stat(p.Manager.GetScriptPath()); os.IsNotExist(err) {
|
||||||
// Script doesn't exist, this is a fatal error
|
// Script doesn't exist, return error so caller can fall back to other criteria
|
||||||
buf := make([]byte, 1024*1024)
|
return false, fmt.Errorf("policy script does not exist at %s", p.Manager.GetScriptPath())
|
||||||
n := runtime.Stack(buf, true)
|
|
||||||
log.E.F("policy script does not exist at %s", p.Manager.GetScriptPath())
|
|
||||||
fmt.Fprintf(os.Stderr, "FATAL: Policy script required but not found at %s\n", p.Manager.GetScriptPath())
|
|
||||||
fmt.Fprintf(os.Stderr, "Stack trace:\n%s\n", buf[:n])
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to start the policy and wait for it
|
// Try to start the policy and wait for it
|
||||||
if err := p.Manager.ensureRunning(); err != nil {
|
if err := p.Manager.ensureRunning(); err != nil {
|
||||||
// Startup failed, this is a fatal error
|
// Startup failed, return error so caller can fall back to other criteria
|
||||||
buf := make([]byte, 1024*1024)
|
return false, fmt.Errorf("failed to start policy script: %v", err)
|
||||||
n := runtime.Stack(buf, true)
|
|
||||||
log.E.F("failed to start policy script: %v", err)
|
|
||||||
fmt.Fprintf(os.Stderr, "FATAL: Failed to start policy script: %v\n", err)
|
|
||||||
fmt.Fprintf(os.Stderr, "Stack trace:\n%s\n", buf[:n])
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
v0.21.1
|
v0.21.3
|
||||||
@@ -71,6 +71,9 @@ check_go_installation() {
|
|||||||
install_go() {
|
install_go() {
|
||||||
log_info "Installing Go $GO_VERSION..."
|
log_info "Installing Go $GO_VERSION..."
|
||||||
|
|
||||||
|
# Save original directory
|
||||||
|
local original_dir=$(pwd)
|
||||||
|
|
||||||
# Determine architecture
|
# Determine architecture
|
||||||
local arch=$(uname -m)
|
local arch=$(uname -m)
|
||||||
case $arch in
|
case $arch in
|
||||||
@@ -100,13 +103,17 @@ install_go() {
|
|||||||
rm -rf "$GOROOT"
|
rm -rf "$GOROOT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract Go
|
# Extract Go to a temporary location first, then move to final destination
|
||||||
log_info "Extracting Go to $GOROOT..."
|
log_info "Extracting Go..."
|
||||||
tar -xf "$go_archive"
|
tar -xf "$go_archive" -C /tmp
|
||||||
|
mv /tmp/go "$GOROOT"
|
||||||
|
|
||||||
# Clean up
|
# Clean up
|
||||||
rm -f "$go_archive"
|
rm -f "$go_archive"
|
||||||
|
|
||||||
|
# Return to original directory
|
||||||
|
cd "$original_dir"
|
||||||
|
|
||||||
log_success "Go $GO_VERSION installed successfully"
|
log_success "Go $GO_VERSION installed successfully"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,7 +174,10 @@ build_application() {
|
|||||||
log_info "Updating embedded web assets..."
|
log_info "Updating embedded web assets..."
|
||||||
./scripts/update-embedded-web.sh
|
./scripts/update-embedded-web.sh
|
||||||
|
|
||||||
# The update-embedded-web.sh script should have built the binary
|
# Build the binary in the current directory
|
||||||
|
log_info "Building binary in current directory..."
|
||||||
|
CGO_ENABLED=1 go build -o "$BINARY_NAME"
|
||||||
|
|
||||||
if [[ -f "./$BINARY_NAME" ]]; then
|
if [[ -f "./$BINARY_NAME" ]]; then
|
||||||
log_success "ORLY relay built successfully"
|
log_success "ORLY relay built successfully"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,14 +1,40 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
apt -y install build-essential autoconf libtool git wget
|
|
||||||
cd $SCRIPT_DIR
|
# Update package lists
|
||||||
|
apt-get update
|
||||||
|
|
||||||
|
# Try to install from package manager first (much faster)
|
||||||
|
echo "Attempting to install secp256k1 from package manager..."
|
||||||
|
if apt-get install -y libsecp256k1-dev >/dev/null 2>&1; then
|
||||||
|
echo "✓ Installed secp256k1 from package manager"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fall back to building from source if package not available
|
||||||
|
echo "Package not available in repository, building from source..."
|
||||||
|
|
||||||
|
# Install build dependencies
|
||||||
|
apt-get install -y build-essential autoconf automake libtool git wget pkg-config
|
||||||
|
|
||||||
|
cd "$SCRIPT_DIR"
|
||||||
rm -rf secp256k1
|
rm -rf secp256k1
|
||||||
|
|
||||||
|
# Clone and setup secp256k1
|
||||||
git clone https://github.com/bitcoin-core/secp256k1.git
|
git clone https://github.com/bitcoin-core/secp256k1.git
|
||||||
cd secp256k1
|
cd secp256k1
|
||||||
git checkout v0.6.0
|
git checkout v0.6.0
|
||||||
|
|
||||||
|
# Initialize and update submodules
|
||||||
git submodule init
|
git submodule init
|
||||||
git submodule update
|
git submodule update
|
||||||
|
|
||||||
|
# Build and install
|
||||||
./autogen.sh
|
./autogen.sh
|
||||||
./configure --enable-module-schnorrsig --enable-module-ecdh --prefix=/usr
|
./configure --enable-module-schnorrsig --enable-module-ecdh --prefix=/usr
|
||||||
make -j1
|
make -j$(nproc)
|
||||||
sudo make install
|
make install
|
||||||
|
|
||||||
|
cd "$SCRIPT_DIR"
|
||||||
|
|||||||
Reference in New Issue
Block a user