-
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for osx-secure-transport.
- Loading branch information
Showing
16 changed files
with
375 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule m4
updated
2 files
+3 −3 | detect_binding.m4 | |
+1 −1 | ocaml_compilers.m4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
(* -*- mode: tuareg; -*- *) | ||
(***************************************************************************** | ||
Liquidsoap, a programmable audio stream generator. | ||
Copyright 2003-2017 Savonet team | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details, fully stated in the COPYING | ||
file at the root of the liquidsoap distribution. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*****************************************************************************) | ||
|
||
open Dtools | ||
|
||
let conf_harbor_secure_transport = | ||
Conf.void ~p:(Harbor_base.conf_harbor#plug "secure_transport") | ||
"Harbor SecureTransport (OSX SSL implementation) settings." | ||
let conf_harbor_secure_transport_certificate = | ||
Conf.string ~p:(conf_harbor_secure_transport#plug "certificate") ~d:"" | ||
"Path to the server's SSL certificate. (mandatory)" | ||
let conf_harbor_secure_transport_password = | ||
Conf.string ~p:(conf_harbor_secure_transport#plug "password") ~d:"" | ||
"Path to the server's SSL password. (optional, blank if omited)" | ||
|
||
module Monad = Duppy.Monad | ||
module type Monad_t = module type of Monad with module Io := Monad.Io | ||
|
||
type handler = Https_secure_transport.socket = { | ||
ctx: SecureTransport.t; | ||
sock: Unix.file_descr | ||
} | ||
|
||
let read {ctx} buf ofs len = | ||
SecureTransport.read ctx buf ofs len | ||
let read_retry = Stdlib.read_retry read | ||
let write {ctx} buf ofs len = | ||
SecureTransport.write ctx buf ofs len | ||
let sock {sock} = sock | ||
|
||
module Websocket_transport = | ||
struct | ||
type socket = handler | ||
let read = read | ||
let read_retry = Stdlib.read_retry read | ||
let write = write | ||
end | ||
|
||
module Duppy_transport : Duppy.Transport_t with type t = handler = | ||
struct | ||
type t = handler | ||
type bigarray = (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t | ||
let sock = sock | ||
let read = read | ||
let write = write | ||
let ba_write _ _ _ _ = | ||
failwith "Not implemented!" | ||
end | ||
|
||
module Transport = | ||
struct | ||
type socket = handler | ||
let file_descr_of_socket = sock | ||
let read socket len = | ||
let buf = Bytes.create len in | ||
let n = read socket buf 0 len in | ||
buf, n | ||
let accept sock = | ||
let (sock, caller) = Unix.accept sock in | ||
let ctx = | ||
SecureTransport.init SecureTransport.Server SecureTransport.Stream | ||
in | ||
let password = | ||
conf_harbor_secure_transport_password#get | ||
in | ||
let password = | ||
if password = "" then None else Some password | ||
in | ||
let cert = conf_harbor_secure_transport_certificate#get in | ||
begin match SecureTransport.import_p12_certificate ?password cert with | ||
| cert::_ -> SecureTransport.set_certificate ctx cert | ||
| [] -> failwith "No certificate found in p12 file!" | ||
end; | ||
SecureTransport.set_connection ctx sock; | ||
({ctx;sock}, caller) | ||
let close {ctx;sock} = | ||
SecureTransport.close ctx; | ||
Unix.close sock | ||
|
||
module Duppy = | ||
struct | ||
module Io = Duppy.MakeIo(Duppy_transport) | ||
module Monad = | ||
struct | ||
module Io = Duppy.Monad.MakeIo(Io) | ||
include (Monad : Monad_t) | ||
end | ||
end | ||
|
||
module Http = Https_secure_transport | ||
module Websocket = Websocket.Make(Websocket_transport) | ||
end | ||
|
||
module SecureTransport = Harbor.Make(Transport) | ||
|
||
include SecureTransport |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
(* -*- mode: tuareg; -*- *) | ||
(***************************************************************************** | ||
Liquidsoap, a programmable audio stream generator. | ||
Copyright 2003-2017 Savonet team | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details, fully stated in the COPYING | ||
file at the root of the liquidsoap distribution. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*****************************************************************************) | ||
|
||
module SecureTransport_harbor = | ||
struct | ||
include Harbor_secure_transport | ||
let name = "https" | ||
end | ||
|
||
module SecureTransport = Builtins_harbor.Make(SecureTransport_harbor) | ||
|
||
include SecureTransport |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
(***************************************************************************** | ||
Liquidsoap, a programmable audio stream generator. | ||
Copyright 2003-2017 Savonet team | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details, fully stated in the COPYING | ||
file at the root of the liquidsoap distribution. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*****************************************************************************) | ||
|
||
let () = | ||
let add_http_request = Lang_builtins.add_http_request (module Https_secure_transport) in | ||
add_http_request | ||
"https.get" | ||
"Perform a full https GET request and return (status,headers),data." | ||
Lang_builtins.Get; | ||
add_http_request | ||
"https.post" | ||
"Perform a full https POST request and return (status,headers),data." | ||
Lang_builtins.Post; | ||
add_http_request | ||
"https.put" | ||
"Perform a full https PUT request and return (status,headers),data." | ||
Lang_builtins.Put; | ||
add_http_request | ||
"https.head" | ||
"Perform a full https HEAD request and return (status,headers),data." | ||
Lang_builtins.Head; | ||
add_http_request | ||
"https.delete" | ||
"Perform a full https DELETE request and return (status,headers),data." | ||
Lang_builtins.Delete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
(* -*- mode: tuareg; -*- *) | ||
(***************************************************************************** | ||
Liquidsoap, a programmable audio stream generator. | ||
Copyright 2003-2017 Savonet team | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details, fully stated in the COPYING | ||
file at the root of the liquidsoap distribution. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*****************************************************************************) | ||
|
||
module SecureTransport_output = | ||
struct | ||
include Harbor_secure_transport.Transport | ||
let source_name = "output.harbor.ssl" | ||
let source_description = "Encode and output the stream using the SSL OSX harbor server." | ||
end | ||
|
||
module SecureTransport = Harbor_output.Make(SecureTransport_output) | ||
|
||
include SecureTransport |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
(* -*- mode: tuareg; -*- *) | ||
(***************************************************************************** | ||
Liquidsoap, a programmable audio stream generator. | ||
Copyright 2003-2017 Savonet team | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details, fully stated in the COPYING | ||
file at the root of the liquidsoap distribution. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*****************************************************************************) | ||
|
||
module SecureTransport_input = | ||
struct | ||
include Harbor_secure_transport | ||
let init () = () | ||
let source_name = "input.harbor.ssl" | ||
let source_description = "Retrieves the given https stream from the harbor." | ||
end | ||
|
||
module SecureTransport = Harbor_input.Make(SecureTransport_input) | ||
|
||
include SecureTransport |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
(***************************************************************************** | ||
Liquidsoap, a programmable audio stream generator. | ||
Copyright 2003-2017 Savonet team | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details, fully stated in the COPYING | ||
file at the root of the liquidsoap distribution. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*****************************************************************************) | ||
|
||
module Input_https = Http_source.Make(Https_secure_transport) | ||
|
||
let () = | ||
Input_https.register "https" |
Oops, something went wrong.