Skip to content

Commit

Permalink
Merge pull request #1379 from Badgerati/Issue-1291
Browse files Browse the repository at this point in the history
Fixes SSL timeouts when running Pode in PS7.4+
  • Loading branch information
Badgerati authored Aug 30, 2024
2 parents b364ec4 + 22e7d94 commit 9bd51aa
Show file tree
Hide file tree
Showing 28 changed files with 683 additions and 725 deletions.
4 changes: 2 additions & 2 deletions examples/sse.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Start-PodeServer -Threads 3 {
# open local sse connection, and send back data
Add-PodeRoute -Method Get -Path '/data' -ScriptBlock {
ConvertTo-PodeSseConnection -Name 'Data' -Scope Local
Send-PodeSseEvent -Id 1234 -EventType Action -Data 'hello, there!'
Send-PodeSseEvent -Id 1234 -EventType Action -Data 'hello, there!' -FromEvent
Start-Sleep -Seconds 3
Send-PodeSseEvent -Id 1337 -EventType BoldOne -Data 'general kenobi'
Send-PodeSseEvent -Id 1337 -EventType BoldOne -Data 'general kenobi' -FromEvent
}

# home page to get sse events
Expand Down
5 changes: 5 additions & 0 deletions examples/web-pages-https.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Import-Module "$($path)/src/Pode.psm1" -Force -ErrorAction Stop

# create a server, flagged to generate a self-signed cert for dev/testing
Start-PodeServer {
New-PodeLoggingMethod -Terminal | Enable-PodeErrorLogging -Levels Error

# bind to ip/port and set as https with self-signed cert
Add-PodeEndpoint -Address * -Port 8443 -Protocol Https -SelfSigned
Expand All @@ -31,4 +32,8 @@ Start-PodeServer {
Set-PodeResponseStatus -Code 500
}

Add-PodeRoute -Method 'GET' -Path '/test' -ScriptBlock {
Write-PodeTextResponse -Value (Get-Date)
}

}
14 changes: 7 additions & 7 deletions examples/web-pages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ Import-Module "$($path)/src/Pode.psm1" -Force -ErrorAction Stop
# Import-Module Pode

# create a server, and start listening on port 8085
Start-PodeServer -Threads 2 -Verbose {
Start-PodeServer -Threads 1 -Verbose {
# listen on localhost:8085
Add-PodeEndpoint -Address * -Port 8090 -Protocol Http -Name '8090Address'
Add-PodeEndpoint -Address * -Port $Port -Protocol Http -Name '8085Address' -RedirectTo '8090Address'

# allow the local ip and some other ips
Add-PodeAccessRule -Access Allow -Type IP -Values @('127.0.0.1', '[::1]')
Add-PodeAccessRule -Access Allow -Type IP -Values @('192.169.0.1', '192.168.0.2')
# Add-PodeAccessRule -Access Allow -Type IP -Values @('127.0.0.1', '[::1]')
# Add-PodeAccessRule -Access Allow -Type IP -Values @('192.169.0.1', '192.168.0.2')

# deny an ip
Add-PodeAccessRule -Access Deny -Type IP -Values 10.10.10.10
Add-PodeAccessRule -Access Deny -Type IP -Values '10.10.0.0/24'
Add-PodeAccessRule -Access Deny -Type IP -Values all
# Add-PodeAccessRule -Access Deny -Type IP -Values 10.10.10.10
# Add-PodeAccessRule -Access Deny -Type IP -Values '10.10.0.0/24'
# Add-PodeAccessRule -Access Deny -Type IP -Values all

# limit
Add-PodeLimitRule -Type IP -Values all -Limit 100 -Seconds 5
# Add-PodeLimitRule -Type IP -Values all -Limit 100 -Seconds 5

# log requests to the terminal
New-PodeLoggingMethod -Terminal -Batch 10 -BatchTimeout 10 | Enable-PodeRequestLogging
Expand Down
1 change: 1 addition & 0 deletions src/Listener/Pode.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
<NoWarn>$(NoWarn);SYSLIB0001</NoWarn>
<LangVersion>9.0</LangVersion>
</PropertyGroup>
</Project>
3 changes: 1 addition & 2 deletions src/Listener/PodeConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ public class PodeConnector : IDisposable
{
CancellationToken = cancellationToken == default(CancellationToken)
? cancellationToken
: (new CancellationTokenSource()).Token;
: new CancellationTokenSource().Token;

// IsConnected = true;
IsDisposed = false;
}

Expand Down
Loading

0 comments on commit 9bd51aa

Please sign in to comment.