Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
locka99 committed Mar 29, 2022
1 parent 13e5132 commit 69ebfef
Show file tree
Hide file tree
Showing 607 changed files with 70,434 additions and 145,131 deletions.
718 changes: 689 additions & 29 deletions Cargo.lock

Large diffs are not rendered by default.

93 changes: 16 additions & 77 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,79 +1,18 @@
# These settings are present to demonstrate minimal binary size in release mode. Don't forget to strip the executable
# too.
[profile.release]
opt-level = 'z'
lto = true
panic = 'abort'

[package]
name = "opcua-all"
version = "0.10.0" # OPCUARustVersion
description = "OPC UA client API"
authors = ["Adam Lock <[email protected]>"]
homepage = "https://github.com/locka99/opcua"
license = "MPL-2.0"
keywords = ["opcua","opc","ua"]
categories = ["embedded","network-programming"]
readme = "../README.md"
documentation = "https://docs.rs/opcua-client/"
edition = "2018"

[badges]
travis-ci = { repository = "locka99/opcua" }
appveyor = { repository = "locka99/opcua" }

[features]
default = ["server", "client"]
all = ["server", "client", "console_logging"]
server = ["generated-address-space", "discovery-server-registration"]
client = []
console_logging = ["env_logger"]
# Includes all the code to populate the address space with the default node set. This is something that embedded
# systems may or may not require.
generated-address-space = []
# Allows a server to register itself with a local discovery server. It does so by becoming a client to the LDS,
# which brings in a dependency to opcua-client. Omitting the feature saves some memory.
discovery-server-registration = ["client"]
# OpenSSL can be compiled and statically linked to with this feature
vendored-openssl = ["openssl/vendored"]
# Servers might want to show a web server with metric / diagnostic info
http = ["actix-web"]

[dependencies]
log = "0.4"
chrono = { version = "0.4", features = ["serde"] }
futures = "0.3"
tokio = { version = "1", features = ["full"] }
tokio-util = { version = "0.6", features = ["codec"] }
lazy_static = "1.4.0"
regex = "1.3"
serde = "1.0"
serde_derive = "1.0"
serde_yaml = "0.8"
serde_json = "1.0"
bytes = "1.0.1"
url = "1.6"
time = "0.1"
bitflags = "1.2"
derivative = "1.0"
byteorder = "1.3"
base64 = "0.12"
uuid = { version = "0.8", features = ["v4"] }
openssl = "0.10"
openssl-sys = "0.9"
gethostname = "0.2.1"
libc = "0.2"
foreign-types = "0.3"

[dependencies.env_logger]
env_logger = "0.5"
optional = true


[dependencies.actix-web]
version = "0.7"
optional = true
panic = 'abort'

[dev-dependencies]
tempdir = "0.3"
serde_json = "1.0"
[workspace]
members = [
"lib",
"integration",
"samples/demo-server",
"samples/simple-client",
"samples/mqtt-client",
"samples/simple-server",
"samples/chess-server",
"samples/modbus-server",
"samples/discovery-client",
"samples/web-client",
"samples/event-client",
"tools/certificate-creator"
]
21 changes: 3 additions & 18 deletions integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,7 @@ edition = "2018"
log = "0.4"
chrono = "0.4"

[dev-dependencies.opcua-server]
path = "../server"
version = "0.10.0" # OPCUARustVersion

[dev-dependencies.opcua-client]
path = "../client"
version = "0.10.0" # OPCUARustVersion

[dev-dependencies.opcua-crypto]
path = "../crypto"
version = "0.10.0" # OPCUARustVersion

[dev-dependencies.opcua-core]
path = "../core"
version = "0.10.0" # OPCUARustVersion

[dev-dependencies.opcua-console-logging]
path = "../console-logging"
[dev-dependencies.opcua-rs]
path = "../lib"
version = "0.10.0" # OPCUARustVersion
features = ["all"]
8 changes: 4 additions & 4 deletions integration/src/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use std::{
use chrono::Utc;
use log::*;

use opcua_client::prelude::*;
use opcua_console_logging;
use opcua_core::{self, runtime_components};
use opcua_server::{
use crate::client::prelude::*;
use crate::console_logging;
use crate::core::{self, runtime_components};
use crate::server::{
self, builder::ServerBuilder, callbacks, config::ServerEndpoint, prelude::*,
session::SessionManager,
};
Expand Down
6 changes: 3 additions & 3 deletions integration/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use std::{
thread,
};

use crate::client::prelude::*;
use crate::console_logging;
use crate::server::{self, prelude::*};
use chrono::Utc;
use log::*;
use opcua_client::prelude::*;
use opcua_console_logging;
use opcua_server::{self, prelude::*};

use crate::harness::*;

Expand Down
74 changes: 74 additions & 0 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
[package]
name = "opcua-rs"
version = "0.10.0" # OPCUARustVersion
description = "OPC UA client API"
authors = ["Adam Lock <[email protected]>"]
homepage = "https://github.com/locka99/opcua"
license = "MPL-2.0"
keywords = ["opcua","opc","ua"]
categories = ["embedded","network-programming"]
readme = "../README.md"
documentation = "https://docs.rs/opcua-client/"
edition = "2018"

[lib]
name = "opcua"

[badges]
travis-ci = { repository = "locka99/opcua" }
appveyor = { repository = "locka99/opcua" }

[features]
default = ["server", "client"]
all = ["server", "client", "console-logging"]
server = ["generated-address-space", "discovery-server-registration"]
client = []
console-logging = ["env_logger"]
# Includes all the code to populate the address space with the default node set. This is something that embedded
# systems may or may not require.
generated-address-space = []
# Allows a server to register itself with a local discovery server. It does so by becoming a client to the LDS,
# which brings in a dependency to opcua-client. Omitting the feature saves some memory.
discovery-server-registration = ["client"]
# OpenSSL can be compiled and statically linked to with this feature
vendored-openssl = ["openssl/vendored"]
# Servers might want to show a web server with metric / diagnostic info
http = ["actix-web"]

[dependencies]
log = "0.4"
chrono = { version = "0.4", features = ["serde"] }
futures = "0.3"
tokio = { version = "1", features = ["full"] }
tokio-util = { version = "0.6", features = ["codec"] }
lazy_static = "1.4.0"
regex = "1.3"
serde = "1.0"
serde_derive = "1.0"
serde_yaml = "0.8"
serde_json = "1.0"
bytes = "1.0.1"
url = "1.6"
time = "0.1"
bitflags = "1.2"
derivative = "1.0"
byteorder = "1.3"
base64 = "0.12"
uuid = { version = "0.8", features = ["v4"] }
openssl = "0.10"
openssl-sys = "0.9"
gethostname = "0.2.1"
libc = "0.2"
foreign-types = "0.3"

[dependencies.env_logger]
env_logger = "0.5"
optional = true

[dependencies.actix-web]
version = "0.7"
optional = true

[dev-dependencies]
tempdir = "0.3"
serde_json = "1.0"
6 changes: 3 additions & 3 deletions src/client/builder.rs → lib/src/client/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

use std::path::PathBuf;

use opcua_core::config::Config;
use crate::core::config::Config;

use crate::{client::*, config::*};
use super::{config::*, *};

/// The `ClientBuilder` is a builder for producing a [`Client`]. It is an alternative to constructing
/// a [`ClientConfig`] from file or from scratch.
///
/// # Example
///
/// ```no_run
/// use opcua_client::prelude::*;
/// use crate::client::prelude::*;
///
/// fn main() {
/// let builder = ClientBuilder::new()
Expand Down
4 changes: 2 additions & 2 deletions src/client/callbacks.rs → lib/src/client/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
use std::fmt;

use opcua_types::{service_types::EventNotificationList, status_code::StatusCode};
use crate::types::{service_types::EventNotificationList, status_code::StatusCode};

use crate::subscription::MonitoredItem;
use super::subscription::MonitoredItem;

/// The `OnSubscriptionNotification` trait is the callback registered along with a new subscription to
/// receive subscription notification callbacks.
Expand Down
37 changes: 20 additions & 17 deletions src/client/client.rs → lib/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@

//! Client setup and session creation.
use crate::{
core::{
comms::url::{
hostname_from_url, is_opc_ua_binary_url, is_valid_opc_ua_url,
server_url_from_endpoint_url, url_matches_except_host, url_with_replaced_hostname,
},
config::Config,
},
crypto::{CertificateStore, SecurityPolicy},
trace_read_lock,
types::{
service_types::{ApplicationDescription, EndpointDescription, RegisteredServer},
status_code::StatusCode,
DecodingOptions, MessageSecurityMode,
},
};

use std::{
path::PathBuf,
str::FromStr,
Expand All @@ -12,21 +29,7 @@ use std::{

use chrono::Duration;

use opcua_core::{
comms::url::{
hostname_from_url, is_opc_ua_binary_url, is_valid_opc_ua_url, server_url_from_endpoint_url,
url_matches_except_host, url_with_replaced_hostname,
},
config::Config,
};
use opcua_crypto::{CertificateStore, SecurityPolicy};
use opcua_types::{
service_types::{ApplicationDescription, EndpointDescription, RegisteredServer},
status_code::StatusCode,
DecodingOptions, MessageSecurityMode,
};

use crate::{
use super::{
config::{ClientConfig, ClientEndpoint, ANONYMOUS_USER_TOKEN_ID},
session::{
services::*,
Expand Down Expand Up @@ -102,7 +105,7 @@ impl Client {
/// # Example
///
/// ```no_run
/// use opcua_client::prelude::*;
/// use crate::client::prelude::*;
/// use std::path::PathBuf;
///
/// fn main() {
Expand Down Expand Up @@ -440,7 +443,7 @@ impl Client {
/// # Example
///
/// ```no_run
/// use opcua_client::prelude::*;
/// use crate::client::prelude::*;
/// use std::path::PathBuf;
///
/// fn main() {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ use std::{
use futures::StreamExt;
use tokio::{
self,
io::{self, ReadHalf, WriteHalf},
io::{self, AsyncWriteExt, ReadHalf, WriteHalf},
net::TcpStream,
sync::mpsc::{UnboundedReceiver, UnboundedSender},
time::{interval, Duration},
};
use tokio_util::codec::FramedRead;

use opcua_core::comms::message_chunk_info::ChunkInfo;
use opcua_core::{
use crate::core::{
comms::{
message_chunk_info::ChunkInfo,
message_writer::MessageWriter,
tcp_codec::{Message, TcpCodec},
tcp_types::HelloMessage,
Expand All @@ -36,15 +36,14 @@ use opcua_core::{
prelude::*,
RUNTIME,
};
use opcua_types::status_code::StatusCode;
use crate::types::status_code::StatusCode;

use crate::{
use crate::client::{
callbacks::OnSessionClosed,
comms::transport::Transport,
message_queue::{self, MessageQueue},
session::session_state::{ConnectionState, ConnectionStateMgr, SessionState},
};
use tokio::io::AsyncWriteExt;

//todo move this struct to core module
#[derive(Debug)]
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions src/client/config.rs → lib/src/client/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ use std::{
str::FromStr,
};

use opcua_core::config::Config;
use opcua_crypto::SecurityPolicy;
use opcua_types::{ApplicationType, MessageSecurityMode, UAString};
use crate::core::config::Config;
use crate::crypto::SecurityPolicy;
use crate::types::{ApplicationType, MessageSecurityMode, UAString};

use crate::session_retry_policy::SessionRetryPolicy;
use super::session_retry_policy::SessionRetryPolicy;

pub const ANONYMOUS_USER_TOKEN_ID: &str = "ANONYMOUS";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{collections::HashMap, sync::mpsc::SyncSender};

use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender};

use opcua_core::supported_message::SupportedMessage;
use crate::core::supported_message::SupportedMessage;

pub(crate) struct MessageQueue {
/// The requests that are in-flight, defined by their request handle and optionally a sender that will be notified with the response.
Expand Down
Loading

0 comments on commit 69ebfef

Please sign in to comment.